Skip to content
This repository has been archived by the owner on Sep 9, 2023. It is now read-only.

Add Drawable API #66

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*'
WarningsAsErrors: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
User: joshuam
CheckOptions:
- key: cert-dcl16-c.NewSuffixes
value: 'L;LL;LU;LLU'
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
value: '0'
- key: cert-str34-c.DiagnoseSignedUnsignedCharComparisons
value: '0'
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
value: '1'
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: '1'
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: llvm-else-after-return.WarnOnConditionVariables
value: '0'
- key: llvm-else-after-return.WarnOnUnfixable
value: '0'
- key: llvm-qualified-auto.AddConstToQualified
value: '0'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
- key: readability-identifier-naming.StructCase
value: 'CamelCase'
- key: readability-identifier-naming.FunctionCase
value: 'lower_case'
- key: readability-identifier-naming.VariableCase
value: 'lower_case'
- key: readability-identifier-naming.GlobalConstantCase
value: 'UPPER_CASE'
- key: readability-identifier-naming.ConstantCase
value: 'UPPER_CASE'
...

36 changes: 36 additions & 0 deletions docs/drawable_api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Drawable API Design Document

# Creating a Drawable

```c
DrawableTextures *textures = drawable_get_textures();
Drawable drawable = {
.x = 0,
.y = SCREEN_HEIGHT - 32,
.enabled = enabled,
.value.texture = textures->status_bar,
.type = DRAWABLE_TEXTURE
};

// Under the hood this uses the DrawableRegistry
drawable_create_drawable(&drawable, "statusbar");
```

# Destroying a drawable

```c
// Again, using the DrawableRegistry under the hood
drawable_destroy_drawable(drawable, "statusbar");

// All Drawables can be destroyed (such as at exit), just a wrapper
around the DrawableRegistry.
drawables_destroy_all();
```

## Accessing a Drawable

```c
// Again, wrapper around the Drawable registry
Drawable *drawable = drawable_get_drawable(drawable, "statusbar");
*drawable->value.number = &plyr_ammo;
```
12 changes: 9 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project('mindoom', 'c',
default_options: ['default_library=static', 'buildtype=debugoptimized'])
default_options: ['default_library=static', 'buildtype=debug'])
add_project_arguments('-DLOG_USE_COLOR', language: 'c')

sdl2 = dependency('SDL2')
Expand Down Expand Up @@ -38,6 +38,12 @@ dedicated_server_source_files = files(
src_dir / 'net_structrw.c',
)

# Source files for the game engine
engine_src_dir = src_dir / 'engine'
engine_source_files = files (
engine_src_dir / 'graphics' / 'widget.c',
engine_src_dir / 'graphics' / 'drawable.c',
)

# Source files only used by the game binary
doom_source_dir = 'doom'
Expand Down Expand Up @@ -135,8 +141,7 @@ game_source_files = files(
src_dir / doom_source_dir / 's_sound.c',
src_dir / doom_source_dir / 'statdump.c',

# Code for the HUD
src_dir / doom_source_dir / 'hud' / 'widget.c',
# Code for the status bar
src_dir / doom_source_dir / 'hud' / 'statusbar.c',

src_dir / doom_source_dir / 'wi_stuff.c'
Expand Down Expand Up @@ -210,6 +215,7 @@ executable('mindoom',
sources: [
common_source_files,
game_source_files,
engine_source_files
],
link_with: [
textscreen,
Expand Down
3 changes: 3 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# mindoom

These scripts are intended to be called by Meson as run targets. Don't call them directly, instead use `meson compile scriptname` from the build directory.
3 changes: 3 additions & 0 deletions src/d_mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

typedef enum
{
//TODO: remove
doom, // Doom 1
heretic, // Heretic
hexen, // Hexen
Expand All @@ -36,6 +37,7 @@ typedef enum
// in: eg. shareware vs. registered. So doom1.wad and doom.wad are the
// same mission, but a different mode.

// TODO: remove
typedef enum
{
registered, // Doom registered
Expand All @@ -44,6 +46,7 @@ typedef enum

// What version are we emulating?

// TODO: remove
typedef enum
{
exe_doom_1_9, // Doom 1.9: "
Expand Down
Loading