Some refactoring

* Added (and fixed) a few useful warnings
    * Removed some dead code
    * Cleaned up the build system files a bit
    * Once again separated ZIP support from data packaging
    * Converted macOS cross-compilation options into cross-file properties
This commit is contained in:
Andrei Alexeyev 2019-01-24 22:21:08 +02:00
parent 4159ea1249
commit fa802dbd94
No known key found for this signature in database
GPG key ID: 363707CD4C7FE8A4
56 changed files with 569 additions and 592 deletions

View file

@ -52,7 +52,7 @@ if get_option('docs')
foreach f : txt_docs
custom_target(f,
command : [eolconv, host_eol_style, '@INPUT@', '@OUTPUT@'],
command : [eolconv_command, host_eol_style, '@INPUT@', '@OUTPUT@'],
input : f,
output : f,
install : true,
@ -63,7 +63,7 @@ if get_option('docs')
foreach f : rst_docs
name = f.split('.')[0] + '.html'
custom_target(name,
command : [eolconv, host_eol_style, '@INPUT@', '@OUTPUT@'],
command : [eolconv_command, host_eol_style, '@INPUT@', '@OUTPUT@'],
input : rst_to_html.process(f),
output : name,
install : true,
@ -74,7 +74,7 @@ if get_option('docs')
if angle_enabled and host_machine.system() == 'windows'
custom_target(f,
command : [eolconv, host_eol_style, '@INPUT@', '@OUTPUT@'],
command : [eolconv_command, host_eol_style, '@INPUT@', '@OUTPUT@'],
input : 'LICENSE.ANGLE',
output : 'LICENSE.txt',
install : true,

View file

@ -1,6 +1,6 @@
project('taisei', 'c',
license : 'MIT',
version : 'v1.2',
version : 'v1.3-dev',
meson_version : '>=0.45.0',
default_options : [
'c_std=c11',
@ -9,101 +9,56 @@ project('taisei', 'c',
'buildtype=release',
'strip=true',
'b_lto=true',
'b_ndebug=true',
'b_ndebug=if-release',
]
)
ver_fb = get_option('version_fallback').strip()
version_fallback = ver_fb != '' ? ver_fb : meson.project_version()
cc = meson.get_compiler('c')
python3 = import('python3').find_python()
macos_app_bundle = get_option('macos_bundle') and host_machine.system() == 'darwin'
common_taiseilib_args = [
'--rootdir', meson.source_root(),
'--fallback-version', version_fallback
]
common_taiseilib_defs = [
'-DMESON_BUILD_TYPE=@0@'.format(get_option('buildtype')),
'-DMESON_BUILD_ROOT=@0@'.format(meson.build_root()),
'-DMESON_SOURCE_ROOT=@0@'.format(meson.source_root()),
]
scripts_dir = 'scripts'
version_script = find_program(join_paths(scripts_dir, 'version.py'))
version_command = [version_script, common_taiseilib_args]
preprocess_script = find_program(join_paths(scripts_dir, 'configure-file.py'))
preprocess_args = common_taiseilib_args + common_taiseilib_defs
preprocess_command = [preprocess_script, preprocess_args]
preprocessor = generator(preprocess_script,
arguments: preprocess_args + ['@EXTRA_ARGS@', '--depfile', '@DEPFILE@', '@INPUT@', '@OUTPUT@'],
output: '@BASENAME@',
depfile: '@BASENAME@.d',
)
eolconv = find_program(join_paths(scripts_dir, 'eolconv.py'))
host_eol_style = host_machine.system() == 'windows' ? 'crlf' : 'lf'
taisei_version_result = run_command(version_command, '{string}')
if taisei_version_result.stderr() != ''
warning(taisei_version_result.stderr().strip())
endif
if taisei_version_result.returncode() != 0
error('Version script exited with code @0@'.format(
taisei_version_result.returncode()
))
endif
taisei_version_string = taisei_version_result.stdout().strip()
subdir('scripts')
config = configuration_data()
cc = meson.get_compiler('c')
python3 = import('python3').find_python()
taisei_c_args = cc.get_supported_arguments(
'-Wall',
'-Wpedantic',
'-Werror=implicit-function-declaration',
taisei_c_warnargs = []
taisei_c_args = []
#
# Keep the rest sorted
#
foreach flag : [
'-Werror=implicit-function-declaration',
]
if cc.has_argument(flag)
taisei_c_args += flag
endif
endforeach
foreach flag : [
'-Wpedantic',
'-Wparentheses',
'-Wtype-limits',
'-Wstrict-prototypes',
'-Wlong-long',
'-Winit-self',
'-Wnull-dereference',
'-Wformat-pedantic',
'-Wgcc-compat',
'-Wfloat-overflow-conversion',
'-Wfloat-zero-conversion',
'-Wfor-loop-analysis',
'-Wimplicit-fallthrough',
'-Wsometimes-uninitialized',
'-Wunneeded-internal-declaration',
'-Wunreachable-code',
'-Wunreachable-code-loop-increment',
'-Wgnu',
'-Wcast-align',
'-Wcast-align=strict',
'-Wno-long-long',
]
if cc.has_argument(flag)
taisei_c_warnargs += flag
endif
endforeach
taisei_c_args += taisei_c_warnargs
'-Wabsolute-value',
'-Wcast-align',
'-Wcast-align=strict',
'-Wclobbered',
'-Wduplicated-branches',
'-Wduplicated-cond',
'-Wfloat-overflow-conversion',
'-Wfloat-zero-conversion',
'-Wfor-loop-analysis',
'-Wformat-pedantic',
'-Wformat-security',
'-Wgcc-compat',
'-Wgnu',
'-Wignored-qualifiers',
'-Wimplicit-fallthrough',
'-Winit-self',
'-Wlogical-op',
'-Wmissing-prototypes',
'-Wno-long-long',
'-Wnull-dereference',
'-Wparentheses',
'-Wshadow=compatible-local',
'-Wsometimes-uninitialized',
'-Wstrict-prototypes',
'-Wtype-limits',
'-Wunneeded-internal-declaration',
'-Wunreachable-code',
'-Wunreachable-code-loop-increment',
)
static = get_option('static')
@ -144,18 +99,28 @@ if host_machine.system() == 'windows'
taisei_deps += cc.find_library('shlwapi')
endif
package_data = get_option('package_data')
enable_zip = get_option('enable_zip')
package_data = (package_data == 'auto' ? enable_zip : package_data == 'true')
if enable_zip
if not dep_zip.found()
error('ZIP support enabled but libzip not found')
endif
taisei_deps += dep_zip
endif
if package_data and not enable_zip
error('ZIP support must be enabled for data packaging to work')
endif
if dep_sdl2_mixer.found() and get_option('enable_audio') != 'false'
taisei_deps += dep_sdl2_mixer
elif get_option('enable_audio') == 'true'
error('Audio support enabled but SDL2_mixer not found')
endif
if dep_zip.found() and get_option('package_data') != 'false'
taisei_deps += dep_zip
elif get_option('package_data') == 'true'
error('Data packaging enabled but libzip not found')
endif
config.set('TAISEI_BUILDCONF_USE_ZIP', taisei_deps.contains(dep_zip))
have_posix = cc.has_header_symbol('unistd.h', '_POSIX_VERSION')
@ -172,8 +137,6 @@ config.set('TAISEI_BUILDCONF_HAVE_TIMESPEC', have_timespec)
config.set('TAISEI_BUILDCONF_HAVE_INT128', cc.sizeof('__int128') == 16)
config.set('TAISEI_BUILDCONF_HAVE_LONG_DOUBLE', cc.sizeof('long double') > 8)
macos_app_bundle = get_option('macos_bundle') and host_machine.system() == 'darwin'
if macos_app_bundle
bundle_dir = 'Taisei.app'
datadir = join_paths(bundle_dir, 'Contents', 'Resources')
@ -184,9 +147,9 @@ if macos_app_bundle
meson.add_install_script(
python3.path(),
join_paths(meson.source_root(), 'scripts', 'macos-install-dylibs.py'),
get_option('macos_lib_path'),
get_option('macos_tool_path'),
get_option('macos_tool_prefix'),
':'.join(meson.get_cross_property('macos_lib_path', [])),
':'.join(meson.get_cross_property('macos_tool_path', [])),
meson.get_cross_property('macos_tool_prefix', ''),
)
else
datadir = get_option('datadir')
@ -243,7 +206,7 @@ angle_enabled = get_option('install_angle')
if host_machine.system() == 'windows'
custom_target('COPYING.txt',
command : [eolconv, 'crlf', '@INPUT@', '@OUTPUT@'],
command : [eolconv_command, host_eol_style, '@INPUT@', '@OUTPUT@'],
input : 'COPYING',
output : 'COPYING.txt',
install : true,
@ -268,6 +231,10 @@ endif
systype = (have_posix ? 'POSIX (@0@)' : '@0@').format(host_machine.system())
systype = '@0@, @1@, @2@'.format(systype, host_machine.cpu_family(), host_machine.cpu())
if meson.is_cross_build()
systype = '@0@ (cross-compiling)'.format(systype)
endif
summary = '''
Summary:
@ -307,10 +274,7 @@ subdir('external')
subdir('resources')
subdir('doc')
subdir('xdg')
subdir('scripts')
subdir('atlas')
subdir('src')
message(summary)
run_command(find_program(join_paths(scripts_dir, 'dump-build-options.py')), meson.build_root())

View file

@ -8,14 +8,21 @@ option(
'enable_audio',
type : 'combo',
choices : ['auto', 'true', 'false'],
description : 'Enable audio support (needs SDL2_mixer)'
description : 'Enable audio support (requires SDL2_mixer)'
)
option(
'enable_zip',
type : 'boolean',
value : 'true',
description : 'Enable loading of game data from ZIP packages (requires libzip)'
)
option(
'package_data',
type : 'combo',
choices : ['auto', 'true', 'false'],
description : 'Package the games assets into a compressed archive instead of bundling plain files (needs libzip)'
description : 'Package the games assets into a compressed archive (requires enable_zip)'
)
option(
@ -86,24 +93,6 @@ option(
description : 'Make a macOS application bundle on install (ignored on other platforms)'
)
option(
'macos_lib_path',
type : 'string',
description : 'List of paths (separated like the PATH environment variable) from where required runtime libraries will be copied into the bundle (useful for cross-compiling)'
)
option(
'macos_tool_path',
type : 'string',
description : 'List of paths (separated like the PATH environment variable) from where macOS-specific utilities (such as otool and install_name_tool) can be found. This is prepended to PATH (useful for cross-compiling)'
)
option(
'macos_tool_prefix',
type : 'string',
description : 'Names of macOS-specific tools are prefixed with this string (useful for cross-compiling)'
)
option(
'docs',
type : 'boolean',
@ -115,7 +104,7 @@ option(
'shader_transpiler',
type : 'boolean',
value : false,
description : 'Enable shader trans-compilation. Requires shaderc'
description : 'Enable shader trans-compilation (requires shaderc)'
)
option(

View file

@ -23,6 +23,6 @@
<key>CFBundleVersion</key>
<string>${VERSION({major}.{minor}.{patch}.{tweak})}</string>
<key>NSHumanReadableCopyright</key>
<string>© 2011-2018, Taisei Project</string>
<string>© 2011-2019, Taisei Project</string>
</dict>
</plist>

View file

@ -15,7 +15,7 @@ endif
if angle_enabled and host_machine.system() == 'windows'
angle_launcher = 'taisei-angle.bat'
custom_target(angle_launcher,
command : [eolconv, host_eol_style, '--no-bom', '@INPUT@', '@OUTPUT@'],
command : [eolconv_command, host_eol_style, '--no-bom', '@INPUT@', '@OUTPUT@'],
input : angle_launcher,
output : angle_launcher,
install : true,

View file

@ -3,7 +3,7 @@ subdir('shader')
dirs = ['bgm', 'gfx', 'models', 'sfx', 'shader', 'fonts']
if taisei_deps.contains(dep_zip)
if package_data
archive = '00-taisei.zip'
pack_exe = find_program('../scripts/pack.py')
pack = custom_target('packed data files',
@ -11,9 +11,8 @@ if taisei_deps.contains(dep_zip)
'@OUTPUT@',
meson.current_source_dir(),
'@DEPFILE@',
'@INPUT@'
dirs,
],
input : dirs,
output : archive,
depfile : 'pack.d',
install : true,

View file

@ -3,15 +3,14 @@
from taiseilib.common import (
run_main,
in_dir,
meson_introspect, meson,
add_common_args,
)
import os
import subprocess
def main(args):
with in_dir(args[1]):
with in_dir(os.environ['MESON_BUILD_ROOT']):
with open('saved_options.json', 'wb') as outfile:
outfile.write(subprocess.check_output(['meson', 'introspect', '--buildoptions']))

View file

@ -1,4 +1,47 @@
ver_fb = get_option('version_fallback').strip()
version_fallback = ver_fb != '' ? ver_fb : meson.project_version()
common_taiseilib_args = [
'--rootdir', meson.source_root(),
'--fallback-version', version_fallback
]
common_taiseilib_defs = [
'-DMESON_BUILD_TYPE=@0@'.format(get_option('buildtype')),
'-DMESON_BUILD_ROOT=@0@'.format(meson.build_root()),
'-DMESON_SOURCE_ROOT=@0@'.format(meson.source_root()),
]
version_script = find_program(files('version.py'))
version_command = [version_script, common_taiseilib_args]
taisei_version_result = run_command(version_command, '{string}')
if taisei_version_result.stderr() != ''
warning(taisei_version_result.stderr().strip())
endif
if taisei_version_result.returncode() != 0
error('Version script exited with code @0@'.format(
taisei_version_result.returncode()
))
endif
taisei_version_string = taisei_version_result.stdout().strip()
preprocess_script = find_program(files('configure-file.py'))
preprocess_args = common_taiseilib_args + common_taiseilib_defs
preprocess_command = [preprocess_script, preprocess_args]
preprocessor = generator(preprocess_script,
arguments: preprocess_args + ['@EXTRA_ARGS@', '--depfile', '@DEPFILE@', '@INPUT@', '@OUTPUT@'],
output: '@BASENAME@',
depfile: '@BASENAME@.d',
)
eolconv_command = find_program(files('eolconv.py'))
host_eol_style = host_machine.system() == 'windows' ? 'crlf' : 'lf'
if get_option('buildtype').contains('debug')
dist_version_string = '@0@-@1@'.format(taisei_version_string, get_option('buildtype'))
else
@ -6,7 +49,7 @@ else
endif
if macos_app_bundle
dmg_command = find_program('./macos-gen-dmg.py')
dmg_command = find_program(files('macos-gen-dmg.py'))
dmg_filename = 'Taisei-@0@-macOS.dmg'.format(dist_version_string)
dmg_target = run_target('dmg',
command: [dmg_command, join_paths(meson.build_root(), dmg_filename), meson.build_root()],
@ -14,7 +57,7 @@ if macos_app_bundle
endif
if host_machine.system() == 'windows'
nsis_command = find_program('./win-gen-nsis.py')
nsis_command = find_program(files('win-gen-nsis.py'))
nsis_filename = 'Taisei-@0@-setup-@1@.exe'.format(dist_version_string, host_machine.cpu_family())
nsis_outpath = join_paths(meson.build_root(), nsis_filename)
@ -47,20 +90,20 @@ if host_machine.system() == 'windows'
)
endif
zip_command = find_program('./gen-zip.py')
zip_command = find_program(files('gen-zip.py'))
zip_filename = 'Taisei-@0@-@1@-@2@.zip'.format(dist_version_string, host_machine.system(), host_machine.cpu_family())
zip_outpath = join_paths(meson.build_root(), zip_filename)
zip_target = run_target('zip',
command: [zip_command, meson.build_root(), zip_outpath],
)
gen_atlas_command = find_program('./gen-atlas.py')
gen_atlases_command = find_program('./gen-atlases.py')
gen_atlas_command = find_program(files('gen-atlas.py'))
gen_atlases_command = find_program(files('gen-atlases.py'))
upkeep_command = find_program('./upkeep.py')
upkeep_script = find_program(files('upkeep.py'))
upkeep_command = [upkeep_script, common_taiseilib_args]
upkeep_target = run_target('upkeep', command: upkeep_command)
upkeep_target = run_target('upkeep',
command: [upkeep_command, common_taiseilib_args],
)
postconf_script = find_program(files('dump-build-options.py'))
# meson.add_postconf_script(postconf_script.path())
run_command(postconf_script)

View file

@ -368,11 +368,11 @@ typedef struct CustomFadeout {
int counter;
} CustomFadeout;
void custom_fadeout_free(int chan, void *udata) {
static void custom_fadeout_free(int chan, void *udata) {
free(udata);
}
void custom_fadeout_proc(int chan, void *stream, int len, void *udata) {
static void custom_fadeout_proc(int chan, void *stream, int len, void *udata) {
CustomFadeout *e = udata;
assert(AUDIO_FORMAT == AUDIO_S16SYS); // if you wanna change the format, you get to implement it here. This is the hardcoded default format in SDL_Mixer by the way

View file

@ -81,7 +81,7 @@ static inline bool healthbar_style_is_radial(void) {
return config_get_int(CONFIG_HEALTHBAR_STYLE) > 0;
}
const Color* boss_healthbar_color(AttackType atype) {
static const Color* boss_healthbar_color(AttackType atype) {
static const Color colors[] = {
[AT_Normal] = { 0.50, 0.50, 0.60, 1.00 },
[AT_Move] = { 1.00, 1.00, 1.00, 1.00 },
@ -385,6 +385,7 @@ static void draw_spell_warning(Font *font, float y_pos, float f, float opacity)
static void draw_spell_name(Boss *b, int time, bool healthbar_radial) {
Font *font = get_font("standard");
complex x0 = VIEWPORT_W/2+I*VIEWPORT_H/3.5;
float f = clamp((time - 40.0) / 60.0, 0, 1);
float f2 = clamp(time / 80.0, 0, 1);
@ -442,7 +443,7 @@ static void draw_spell_name(Boss *b, int time, bool healthbar_radial) {
float a = clamp((global.frames - b->current->starttime - 60) / 60.0, 0, 1);
snprintf(buf, sizeof(buf), "%u / %u", p->num_cleared, p->num_played);
Font *font = get_font("small");
font = get_font("small");
draw_boss_text(ALIGN_RIGHT,
(VIEWPORT_W - 10) + (text_width(font, buf, 0) + 10) * pow(1 - a, 2),
@ -652,7 +653,7 @@ void draw_boss_hud(Boss *boss) {
}
}
void boss_rule_extra(Boss *boss, float alpha) {
static void boss_rule_extra(Boss *boss, float alpha) {
if(global.frames % 5) {
return;
}
@ -1197,7 +1198,7 @@ Attack* boss_add_attack(Boss *boss, AttackType type, char *name, float timeout,
return a;
}
void boss_generic_move(Boss *b, int time) {
static void boss_generic_move(Boss *b, int time) {
Attack *atck = b->current;
if(atck->info->pos_dest == BOSS_NOMOVE) {

View file

@ -310,12 +310,7 @@ static void credits_draw_entry(CreditsEntry *e) {
*/
r_color(RGBA_MUL_ALPHA(1, 1, 1, fadein * fadeout));
if(yukkuri) {
r_mat_translate(0, (-h_body) * 0.5, 0);
} else {
r_mat_translate(0, (-h_body) * 0.5, 0);
}
r_mat_translate(0, h_body * -0.5, 0);
for(int i = 0; i < e->lines; ++i) {
if(yukkuri && !i) {

View file

@ -98,7 +98,7 @@ Enemy *create_enemy_p(EnemyList *enemies, complex pos, float hp, EnemyVisualRule
return e;
}
void* _delete_enemy(ListAnchor *enemies, List* enemy, void *arg) {
static void* _delete_enemy(ListAnchor *enemies, List* enemy, void *arg) {
Enemy *e = (Enemy*)enemy;
if(e->hp <= 0 && e->hp != ENEMY_IMMUNE && e->hp != ENEMY_BOMB) {

View file

@ -100,7 +100,7 @@ void delete_items(void) {
}
}
complex move_item(Item *i) {
static complex move_item(Item *i) {
int t = global.frames - i->birthtime;
complex lim = 0 + 2.0*I;
@ -109,7 +109,6 @@ complex move_item(Item *i) {
if(i->auto_collect) {
i->pos -= (7+i->auto_collect)*cexp(I*carg(i->pos - global.plr.pos));
} else {
complex oldpos = i->pos;
i->pos = i->pos0 + log(t/5.0 + 1)*5*(i->v + lim) + lim*t;
complex v = i->pos - oldpos;

View file

@ -314,7 +314,7 @@ static void lasers_ent_postdraw_hook(EntityInterface *ent, void *arg) {
}
}
void* _delete_laser(ListAnchor *lasers, List *laser, void *arg) {
static void* _delete_laser(ListAnchor *lasers, List *laser, void *arg) {
Laser *l = (Laser*)laser;
if(l->lrule)
@ -326,7 +326,7 @@ void* _delete_laser(ListAnchor *lasers, List *laser, void *arg) {
return NULL;
}
void delete_laser(LaserList *lasers, Laser *laser) {
static void delete_laser(LaserList *lasers, Laser *laser) {
_delete_laser((ListAnchor*)lasers, (List*)laser, NULL);
}

View file

@ -111,7 +111,7 @@ static void log_lib_versions(void) {
log_info("Using libpng %s", png_get_header_ver(NULL));
}
void log_system_specs(void) {
static void log_system_specs(void) {
log_info("CPU count: %d", SDL_GetCPUCount());
// log_info("CPU type: %s", SDL_GetCPUType());
// log_info("CPU name: %s", SDL_GetCPUName());

View file

@ -8,21 +8,22 @@
#include "taisei.h"
#include "charselect.h"
#include "menu.h"
#include "options.h"
#include "common.h"
#include "global.h"
#include "video.h"
void set_player(MenuData *m, void *p) {
static void set_player(MenuData *m, void *p) {
progress.game_settings.character = (CharacterID)(uintptr_t)p;
}
void set_shotmode(MenuData *m, void *p) {
static void set_shotmode(MenuData *m, void *p) {
progress.game_settings.shotmode = (ShotModeID)(uintptr_t)p;
}
void create_shottype_menu(MenuData *m) {
static void create_shottype_menu(MenuData *m) {
create_menu(m);
m->transition = NULL;
@ -35,11 +36,10 @@ void create_shottype_menu(MenuData *m) {
}
}
void char_menu_input(MenuData*);
void draw_char_menu(MenuData*);
void free_char_menu(MenuData*);
static void char_menu_input(MenuData*);
static void free_char_menu(MenuData*);
void update_char_menu(MenuData *menu) {
static void update_char_menu(MenuData *menu) {
for(int i = 0; i < menu->ecount; i++) {
menu->entries[i].drawdata += 0.08*(1.0*(menu->cursor != i) - menu->entries[i].drawdata);
}
@ -179,7 +179,7 @@ void draw_char_menu(MenuData *menu) {
r_cull(cull_saved);
}
bool char_menu_input_handler(SDL_Event *event, void *arg) {
static bool char_menu_input_handler(SDL_Event *event, void *arg) {
MenuData *menu = arg;
MenuData *mod = menu->context;
TaiseiEvent type = TAISEI_EVENT(event->type);
@ -217,14 +217,14 @@ bool char_menu_input_handler(SDL_Event *event, void *arg) {
return false;
}
void char_menu_input(MenuData *menu) {
static void char_menu_input(MenuData *menu) {
events_poll((EventHandler[]){
{ .proc = char_menu_input_handler, .arg = menu },
{ NULL }
}, EFLAG_MENU);
}
void free_char_menu(MenuData *menu) {
static void free_char_menu(MenuData *menu) {
MenuData *mod = menu->context;
destroy_menu(mod);
free(mod);

View file

@ -8,6 +8,7 @@
#include "taisei.h"
#include "common.h"
#include "global.h"
#include "menu.h"
#include "savereplay.h"

View file

@ -18,11 +18,11 @@
// FIXME: put this into the menu struct somehow (drawdata is a bad system)
static Color diff_color;
void set_difficulty(MenuData *m, void *d) {
static void set_difficulty(MenuData *m, void *d) {
progress.game_settings.difficulty = (Difficulty)(uintptr_t)d;
}
void update_difficulty_menu(MenuData *menu) {
static void update_difficulty_menu(MenuData *menu) {
menu->drawdata[0] += (menu->cursor-menu->drawdata[0])*0.1;
for(int i = 0; i < menu->ecount; ++i) {

View file

@ -24,22 +24,6 @@
#include "version.h"
#include "plrmodes.h"
void enter_stagepractice(MenuData *menu, void *arg) {
MenuData m;
do {
create_difficulty_menu(&m);
if(menu_loop(&m) < 0) {
return;
}
global.diff = progress.game_settings.difficulty;
create_stgpract_menu(&m, global.diff);
menu_loop(&m);
} while(m.selected < 0 || m.selected == m.ecount - 1);
}
static MenuEntry *spell_practice_entry;
static MenuEntry *stage_practice_entry;
@ -70,7 +54,14 @@ static void begin_main_menu(MenuData *m) {
start_bgm("menu");
}
static void update_main_menu(MenuData *menu);
static void update_main_menu(MenuData *menu) {
menu->drawdata[1] += (text_width(get_font("big"), menu->entries[menu->cursor].name, 0) - menu->drawdata[1])/10.0;
menu->drawdata[2] += (35*menu->cursor - menu->drawdata[2])/10.0;
for(int i = 0; i < menu->ecount; i++) {
menu->entries[i].drawdata += 0.2 * ((i == menu->cursor) - menu->entries[i].drawdata);
}
}
void create_main_menu(MenuData *m) {
create_menu(m);
@ -87,7 +78,7 @@ void create_main_menu(MenuData *m) {
#endif
add_menu_entry(m, "Replays", enter_replayview, NULL);
add_menu_entry(m, "Options", enter_options, NULL);
add_menu_entry(m, "Quit", menu_commonaction_close, NULL)->transition = TransFadeBlack;;
add_menu_entry(m, "Quit", menu_commonaction_close, NULL)->transition = TransFadeBlack;
stage_practice_entry = m->entries + 2;
spell_practice_entry = m->entries + 3;
@ -99,15 +90,6 @@ void draw_main_menu_bg(MenuData* menu) {
fill_screen("menu/mainmenubg");
}
static void update_main_menu(MenuData *menu) {
menu->drawdata[1] += (text_width(get_font("big"), menu->entries[menu->cursor].name, 0) - menu->drawdata[1])/10.0;
menu->drawdata[2] += (35*menu->cursor - menu->drawdata[2])/10.0;
for(int i = 0; i < menu->ecount; i++) {
menu->entries[i].drawdata += 0.2 * ((i == menu->cursor) - menu->entries[i].drawdata);
}
}
void draw_main_menu(MenuData *menu) {
draw_main_menu_bg(menu);
draw_sprite(150.5, 100, "menu/logo");

View file

@ -49,7 +49,7 @@ void create_menu(MenuData *menu) {
menu->input = menu_input;
}
void close_menu_finish(MenuData *menu) {
static void close_menu_finish(MenuData *menu) {
menu->state = MS_Dead;
if(menu->selected != -1 && menu->entries[menu->selected].action != NULL) {

View file

@ -17,19 +17,19 @@
// --- Menu entry <-> config option binding stuff --- //
void bind_init(OptionBinding *bind) {
static void bind_init(OptionBinding *bind) {
memset(bind, 0, sizeof(OptionBinding));
bind->selected = -1;
bind->configentry = -1;
}
OptionBinding* bind_new(void) {
static OptionBinding* bind_new(void) {
OptionBinding *bind = malloc(sizeof(OptionBinding));
bind_init(bind);
return bind;
}
void bind_free(OptionBinding *bind) {
static void bind_free(OptionBinding *bind) {
int i;
if(bind->values) {
@ -39,14 +39,14 @@ void bind_free(OptionBinding *bind) {
}
}
OptionBinding* bind_get(MenuData *m, int idx) {
static OptionBinding* bind_get(MenuData *m, int idx) {
MenuEntry *e = m->entries + idx;
return e->arg == m? NULL : e->arg;
}
// BT_IntValue: integer and boolean options
// Values are defined with bind_addvalue or bind_setrange
OptionBinding* bind_option(int cfgentry, BindingGetter getter, BindingSetter setter) {
static OptionBinding* bind_option(int cfgentry, BindingGetter getter, BindingSetter setter) {
OptionBinding *bind = bind_new();
bind->type = BT_IntValue;
bind->configentry = cfgentry;
@ -58,7 +58,7 @@ OptionBinding* bind_option(int cfgentry, BindingGetter getter, BindingSetter set
}
// BT_KeyBinding: keyboard action mapping options
OptionBinding* bind_keybinding(int cfgentry) {
static OptionBinding* bind_keybinding(int cfgentry) {
OptionBinding *bind = bind_new();
bind->configentry = cfgentry;
@ -68,7 +68,7 @@ OptionBinding* bind_keybinding(int cfgentry) {
}
// BT_GamepadKeyBinding: gamepad action mapping options
OptionBinding* bind_gpbinding(int cfgentry) {
static OptionBinding* bind_gpbinding(int cfgentry) {
OptionBinding *bind = bind_new();
bind->configentry = cfgentry;
@ -78,7 +78,7 @@ OptionBinding* bind_gpbinding(int cfgentry) {
}
// BT_GamepadAxisBinding: gamepad axis mapping options
OptionBinding* bind_gpaxisbinding(int cfgentry) {
static OptionBinding* bind_gpaxisbinding(int cfgentry) {
OptionBinding *bind = bind_new();
bind->configentry = cfgentry;
@ -104,7 +104,7 @@ static int bind_gpdev_set(OptionBinding *b, int v) {
}
// BT_GamepadDevice: dynamic device list
OptionBinding* bind_gpdevice(int cfgentry) {
static OptionBinding* bind_gpdevice(int cfgentry) {
OptionBinding *bind = bind_new();
bind->configentry = cfgentry;
@ -122,7 +122,7 @@ OptionBinding* bind_gpdevice(int cfgentry) {
}
// BT_StrValue: with a half-assed "textbox"
OptionBinding* bind_stroption(ConfigIndex cfgentry) {
static OptionBinding* bind_stroption(ConfigIndex cfgentry) {
OptionBinding *bind = bind_new();
bind->type = BT_StrValue;
bind->configentry = cfgentry;
@ -132,7 +132,7 @@ OptionBinding* bind_stroption(ConfigIndex cfgentry) {
}
// BT_Resolution: super-special binding type for the resolution setting
void bind_resolution_update(OptionBinding *bind) {
static void bind_resolution_update(OptionBinding *bind) {
bind->valcount = video.mcount;
for(int i = 0; i < video.mcount; ++i) {
@ -143,7 +143,7 @@ void bind_resolution_update(OptionBinding *bind) {
}
}
OptionBinding* bind_resolution(void) {
static OptionBinding* bind_resolution(void) {
OptionBinding *bind = bind_new();
bind->type = BT_Resolution;
bind->selected = -1;
@ -152,7 +152,7 @@ OptionBinding* bind_resolution(void) {
}
// BT_Scale: float values clamped to a range
OptionBinding* bind_scale(int cfgentry, float smin, float smax, float step) {
static OptionBinding* bind_scale(int cfgentry, float smin, float smax, float step) {
OptionBinding *bind = bind_new();
bind->type = BT_Scale;
bind->configentry = cfgentry;
@ -165,7 +165,7 @@ OptionBinding* bind_scale(int cfgentry, float smin, float smax, float step) {
}
// Returns a pointer to the first found binding that blocks input. If none found, returns NULL.
OptionBinding* bind_getinputblocking(MenuData *m) {
static OptionBinding* bind_getinputblocking(MenuData *m) {
int i;
for(i = 0; i < m->ecount; ++i) {
OptionBinding *bind = bind_get(m, i);
@ -176,20 +176,21 @@ OptionBinding* bind_getinputblocking(MenuData *m) {
}
// Adds a value to a BT_IntValue type binding
int bind_addvalue(OptionBinding *b, char *val) {
static int bind_addvalue(OptionBinding *b, char *val) {
b->values = realloc(b->values, ++b->valcount * sizeof(char*));
b->values[b->valcount-1] = malloc(strlen(val) + 1);
strcpy(b->values[b->valcount-1], val);
return b->valcount-1;
}
void bind_setvaluerange(OptionBinding *b, int vmin, int vmax) {
attr_unused
static void bind_setvaluerange(OptionBinding *b, int vmin, int vmax) {
b->valrange_min = vmin;
b->valrange_max = vmax;
}
// Called to select a value of a BT_IntValue type binding by index
int bind_setvalue(OptionBinding *b, int v) {
static int bind_setvalue(OptionBinding *b, int v) {
if(b->setter)
return b->selected = b->setter(b, v);
else
@ -197,7 +198,7 @@ int bind_setvalue(OptionBinding *b, int v) {
}
// Called to get the selected value of a BT_IntValue type binding by index
int bind_getvalue(OptionBinding *b) {
static int bind_getvalue(OptionBinding *b) {
if(b->getter) {
if(b->selected >= b->valcount && b->valcount) {
b->selected = 0;
@ -213,7 +214,7 @@ int bind_getvalue(OptionBinding *b) {
}
// Selects the next to current value of a BT_IntValue type binding
int bind_setnext(OptionBinding *b) {
static int bind_setnext(OptionBinding *b) {
int s = b->selected + 1;
if(b->valrange_max) {
@ -227,7 +228,7 @@ int bind_setnext(OptionBinding *b) {
}
// Selects the previous to current value of a BT_IntValue type binding
int bind_setprev(OptionBinding *b) {
static int bind_setprev(OptionBinding *b) {
int s = b->selected - 1;
if(b->valrange_max) {
@ -240,11 +241,11 @@ int bind_setprev(OptionBinding *b) {
return bind_setvalue(b, s);
}
void bind_setdependence(OptionBinding *b, BindingDependence dep) {
static void bind_setdependence(OptionBinding *b, BindingDependence dep) {
b->dependence = dep;
}
bool bind_isactive(OptionBinding *b) {
static bool bind_isactive(OptionBinding *b) {
if(!b->dependence)
return true;
return b->dependence();
@ -252,23 +253,23 @@ bool bind_isactive(OptionBinding *b) {
// --- Shared binding callbacks --- //
int bind_common_onoff_get(OptionBinding *b) {
static int bind_common_onoff_get(OptionBinding *b) {
return !config_get_int(b->configentry);
}
int bind_common_onoff_set(OptionBinding *b, int v) {
static int bind_common_onoff_set(OptionBinding *b, int v) {
return !config_set_int(b->configentry, !v);
}
int bind_common_onoff_inverted_get(OptionBinding *b) {
static int bind_common_onoff_inverted_get(OptionBinding *b) {
return config_get_int(b->configentry);
}
int bind_common_onoff_inverted_set(OptionBinding *b, int v) {
static int bind_common_onoff_inverted_set(OptionBinding *b, int v) {
return config_set_int(b->configentry, v);
}
int bind_common_onoffplus_get(OptionBinding *b) {
static int bind_common_onoffplus_get(OptionBinding *b) {
int v = config_get_int(b->configentry);
if(v > 1)
@ -276,7 +277,7 @@ int bind_common_onoffplus_get(OptionBinding *b) {
return !v;
}
int bind_common_onoffplus_set(OptionBinding *b, int v) {
static int bind_common_onoffplus_set(OptionBinding *b, int v) {
if(v > 1)
return config_set_int(b->configentry, v);
return !config_set_int(b->configentry, !v);
@ -285,34 +286,34 @@ int bind_common_onoffplus_set(OptionBinding *b, int v) {
#define bind_common_int_get bind_common_onoff_inverted_get
#define bind_common_int_set bind_common_onoff_inverted_set
int bind_common_intplus1_get(OptionBinding *b) {
static int bind_common_intplus1_get(OptionBinding *b) {
return config_get_int(b->configentry) - 1;
}
int bind_common_intplus1_set(OptionBinding *b, int v) {
static int bind_common_intplus1_set(OptionBinding *b, int v) {
return config_set_int(b->configentry, v + 1) - 1;
}
// --- Binding callbacks for individual options --- //
bool bind_audio_dependence(void) {
static bool bind_audio_dependence(void) {
return audio_backend_initialized();
}
bool bind_resizable_dependence(void) {
static bool bind_resizable_dependence(void) {
return !config_get_int(CONFIG_FULLSCREEN);
}
bool bind_bgquality_dependence(void) {
static bool bind_bgquality_dependence(void) {
return !config_get_int(CONFIG_NO_STAGEBG);
}
bool bind_resolution_dependence(void) {
static bool bind_resolution_dependence(void) {
return video_can_change_resolution();
}
int bind_resolution_set(OptionBinding *b, int v) {
static int bind_resolution_set(OptionBinding *b, int v) {
if(v >= 0) {
VideoMode *m = video.modes + v;
config_set_int(CONFIG_VID_WIDTH, m->width);
@ -322,17 +323,17 @@ int bind_resolution_set(OptionBinding *b, int v) {
return v;
}
int bind_power_set(OptionBinding *b, int v) {
static int bind_power_set(OptionBinding *b, int v) {
return config_set_int(b->configentry, v * 100) / 100;
}
int bind_power_get(OptionBinding *b) {
static int bind_power_get(OptionBinding *b) {
return config_get_int(b->configentry) / 100;
}
// --- Creating, destroying, filling the menu --- //
void destroy_options_menu(MenuData *m) {
static void destroy_options_menu(MenuData *m) {
for(int i = 0; i < m->ecount; ++i) {
OptionBinding *bind = bind_get(m, i);
@ -363,7 +364,7 @@ static void do_nothing(MenuData *menu, void *arg) { }
static void update_options_menu(MenuData *menu);
void options_menu_input(MenuData*);
void create_options_menu_basic(MenuData *m, char *s) {
static void create_options_menu_basic(MenuData *m, char *s) {
create_menu(m);
m->transition = TransMenuDark;
m->flags = MF_Abortable;
@ -376,7 +377,7 @@ void create_options_menu_basic(MenuData *m, char *s) {
#define bind_onoff(b) bind_addvalue(b, "on"); bind_addvalue(b, "off")
void options_sub_video(MenuData *parent, void *arg) {
static void options_sub_video(MenuData *parent, void *arg) {
MenuData menu, *m;
OptionBinding *b;
m = &menu;
@ -455,7 +456,8 @@ void options_sub_video(MenuData *parent, void *arg) {
parent->frames = 0;
}
void bind_setvaluerange_fancy(OptionBinding *b, int ma) {
attr_unused
static void bind_setvaluerange_fancy(OptionBinding *b, int ma) {
int i = 0; for(i = 0; i <= ma; ++i) {
char tmp[16];
snprintf(tmp, 16, "%i", i);
@ -467,7 +469,7 @@ static bool gamepad_enabled_depencence(void) {
return config_get_int(CONFIG_GAMEPAD_ENABLED);
}
void options_sub_gamepad_controls(MenuData *parent, void *arg) {
static void options_sub_gamepad_controls(MenuData *parent, void *arg) {
MenuData menu, *m;
m = &menu;
@ -516,7 +518,7 @@ void options_sub_gamepad_controls(MenuData *parent, void *arg) {
parent->frames = 0;
}
void options_sub_gamepad(MenuData *parent, void *arg) {
static void options_sub_gamepad(MenuData *parent, void *arg) {
MenuData menu, *m;
OptionBinding *b;
m = &menu;
@ -576,7 +578,7 @@ void options_sub_gamepad(MenuData *parent, void *arg) {
free(gpdev);
}
void options_sub_controls(MenuData *parent, void *arg) {
static void options_sub_controls(MenuData *parent, void *arg) {
MenuData menu, *m;
m = &menu;

View file

@ -356,7 +356,7 @@ static void replayview_draw(MenuData *m) {
r_shader_standard();
}
int replayview_cmp(const void *a, const void *b) {
static int replayview_cmp(const void *a, const void *b) {
ReplayviewItemContext *actx = ((MenuEntry*)a)->arg;
ReplayviewItemContext *bctx = ((MenuEntry*)b)->arg;
@ -366,7 +366,7 @@ int replayview_cmp(const void *a, const void *b) {
return brpy->stages[0].seed - arpy->stages[0].seed;
}
int fill_replayview_menu(MenuData *m) {
static int fill_replayview_menu(MenuData *m) {
VFSDir *dir = vfs_dir_open("storage/replays");
const char *filename;
int rpys = 0;
@ -408,7 +408,7 @@ int fill_replayview_menu(MenuData *m) {
return rpys;
}
void replayview_menu_input(MenuData *m) {
static void replayview_menu_input(MenuData *m) {
ReplayviewContext *ctx = (ReplayviewContext*)m->context;
MenuData *sub = ctx->submenu;
@ -423,7 +423,7 @@ void replayview_menu_input(MenuData *m) {
}
}
void replayview_free(MenuData *m) {
static void replayview_free(MenuData *m) {
if(m->context) {
ReplayviewContext *ctx = m->context;

View file

@ -13,7 +13,7 @@
#include "options.h"
#include "global.h"
void draw_spell_menu(MenuData *m) {
static void draw_spell_menu(MenuData *m) {
draw_options_menu_bg(m);
draw_menu_title(m, "Spell Practice");
draw_menu_list(m, 100, 100, NULL);

View file

@ -13,7 +13,7 @@
#include "options.h"
#include "global.h"
void draw_stgpract_menu(MenuData *m) {
static void draw_stgpract_menu(MenuData *m) {
draw_options_menu_bg(m);