adjustable power in practice mode. closes #107

This commit is contained in:
Andrei Alexeyev 2018-01-20 17:54:45 +02:00
parent 1008e6e41e
commit 2925cf5dd6
No known key found for this signature in database
GPG key ID: 363707CD4C7FE8A4
4 changed files with 31 additions and 5 deletions

View file

@ -88,6 +88,7 @@
CONFIGDEF_INT (NO_STAGEBG, "disable_stagebg", 0) \
CONFIGDEF_INT (SAVE_RPY, "save_rpy", 2) \
CONFIGDEF_INT (SPELLSTAGE_AUTORESTART, "spellpractice_restart_on_fail", 0) \
CONFIGDEF_INT (PRACTICE_POWER, "practice_power", 200) \
CONFIGDEF_FLOAT (TEXT_QUALITY, "text_quality", 1.0) \
CONFIGDEF_FLOAT (FG_QUALITY, "fg_quality", 1.0) \
CONFIGDEF_FLOAT (BG_QUALITY, "bg_quality", 1.0) \

View file

@ -322,6 +322,14 @@ int bind_resolution_set(OptionBinding *b, int v) {
return v;
}
int bind_power_set(OptionBinding *b, int v) {
return config_set_int(b->configentry, v * 100) / 100;
}
int bind_power_get(OptionBinding *b) {
return config_get_int(b->configentry) / 100;
}
// --- Creating, destroying, filling the menu --- //
void destroy_options_menu(MenuData *m) {
@ -678,6 +686,14 @@ void create_options_menu(MenuData *m) {
b = bind_option(CONFIG_SPELLSTAGE_AUTORESTART, bind_common_onoff_get, bind_common_onoff_set)
); bind_onoff(b);
add_menu_entry(m, "Power in Spell and Stage Practice", do_nothing,
b = bind_option(CONFIG_PRACTICE_POWER, bind_power_get, bind_power_set)
); bind_addvalue(b, "0.0");
bind_addvalue(b, "1.0");
bind_addvalue(b, "2.0");
bind_addvalue(b, "3.0");
bind_addvalue(b, "4.0");
add_menu_entry(m, "Shoot by default", do_nothing,
b = bind_option(CONFIG_SHOT_INVERTED, bind_common_onoff_get, bind_common_onoff_set)
); bind_onoff(b);
@ -769,6 +785,9 @@ void draw_options_menu(MenuData *menu) {
char tmp[16]; // who'd use a 16-digit number here anyway?
snprintf(tmp, 16, "%d", bind_getvalue(bind));
draw_text(AL_Right, origin, 20*i, tmp, _fonts.standard);
} else if(bind->configentry == CONFIG_PRACTICE_POWER) {
int stars = PLR_MAX_POWER / 100;
draw_stars(origin - 20 * (stars - 0.5), 20*i, val, 0, stars, 100, alpha, 20);
} else for(j = bind->displaysingle? val : bind->valcount-1; (j+1) && (!bind->displaysingle || j == val); --j) {
if(j != bind->valcount-1 && !bind->displaysingle)
origin -= stringwidth(bind->values[j+1], _fonts.standard) + 5;

View file

@ -33,9 +33,6 @@ enum {
PLR_SCORE_PER_LIFE_FRAG = 55000,
PLR_SCORE_PER_BOMB_FRAG = 22000,
PLR_SPELLPRACTICE_POWER = 200,
PLR_STGPRACTICE_POWER = 200,
PLR_STGPRACTICE_LIVES = PLR_MAX_LIVES,
PLR_STGPRACTICE_BOMBS = PLR_START_BOMBS,

View file

@ -191,13 +191,22 @@ static void stage_start(StageInfo *stage) {
player_stage_pre_init(&global.plr);
if(stage->type == STAGE_SPELL) {
assert(global.is_practice_mode);
global.plr.lives = 0;
global.plr.bombs = 0;
global.plr.power = PLR_SPELLPRACTICE_POWER;
} else if(global.is_practice_mode) {
global.plr.lives = PLR_STGPRACTICE_LIVES;
global.plr.bombs = PLR_STGPRACTICE_BOMBS;
global.plr.power = PLR_STGPRACTICE_POWER;
}
if(global.is_practice_mode) {
global.plr.power = config_get_int(CONFIG_PRACTICE_POWER);
}
if(global.plr.power < 0) {
global.plr.power = 0;
} else if(global.plr.power > PLR_MAX_POWER) {
global.plr.power = PLR_MAX_POWER;
}
reset_sounds();