added set time debug ui

This commit is contained in:
thecozies 2024-04-05 11:25:30 -05:00
parent 50536bf737
commit 65ced0c594
8 changed files with 94 additions and 16 deletions

View File

@ -42,6 +42,63 @@
</div> </div>
</div> </div>
</div> </div>
<div class="config-debug-option">
<label
class="config-debug-option__label"
>
<div>Set time</div>
</label>
<div class="config-debug__option-split">
<div class="config-debug__option-controls">
<div class="config-option__range-wrapper config-debug__select-wrapper config-option__list">
<div class="config-debug__select-label"><div>Day: {{debug_time_day}}</div></div>
<input
data-event-blur="set_cur_config_index(-1)"
data-event-focus="set_cur_config_index(1)"
class="nav-vert"
id="debug_time_set_day"
type="range"
data-value="debug_time_day"
min="0"
max="7"
/>
</div>
<div class="config-option__range-wrapper config-debug__select-wrapper config-option__list">
<div class="config-debug__select-label"><div>Hour: {{debug_time_hour}}</div></div>
<input
data-event-blur="set_cur_config_index(-1)"
data-event-focus="set_cur_config_index(1)"
class="nav-vert"
id="debug_time_set_hour"
type="range"
data-value="debug_time_hour"
min="0"
max="23"
/>
</div>
<div class="config-option__range-wrapper config-debug__select-wrapper config-option__list">
<div class="config-debug__select-label"><div>Minute: {{debug_time_minute}}</div></div>
<input
data-event-blur="set_cur_config_index(-1)"
data-event-focus="set_cur_config_index(1)"
class="nav-vert"
id="debug_time_set_minute"
type="range"
data-value="debug_time_minute"
min="0"
max="59"
/>
</div>
</div>
<div class="config-debug__option-trigger">
<button
class="icon-button icon-button--success" onclick="set_time"
>
<svg src="icons/Arrow.svg" />
</button>
</div>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>

File diff suppressed because one or more lines are too long

View File

@ -101,6 +101,19 @@
} }
} }
input {
@extend %body;
@extend %nav-all;
display: block;
position: relative;
box-sizing: border-box;
padding: 0;
flex: 1 1 100%;
width: auto;
height: space(20);
margin: auto 0;
}
select { select {
@extend %body; @extend %body;
@extend %nav-all; @extend %nav-all;
@ -117,6 +130,10 @@
background-color: $color-white-a5; background-color: $color-white-a5;
cursor: pointer; cursor: pointer;
align-items: center;
justify-content: flex-start;
padding: space(14);
&:hover, &:focus { &:hover, &:focus {
@include border($color-white-a80); @include border($color-white-a80);
background-color: $color-white-a20; background-color: $color-white-a20;
@ -124,9 +141,6 @@
selectvalue { selectvalue {
display: inline; display: inline;
align-items: center;
justify-content: flex-start;
padding: space(14);
margin: auto 0; margin: auto 0;
height: auto; height: auto;
} }

View File

@ -19,7 +19,7 @@ namespace recomp {
extern std::vector<AreaWarps> game_warps; extern std::vector<AreaWarps> game_warps;
void do_warp(int area, int scene, int entrance); void do_warp(int area, int scene, int entrance);
void set_time(uint8_t hour, uint8_t minute); void set_time(uint8_t day, uint8_t hour, uint8_t minute);
} }
#endif #endif

View File

@ -54,11 +54,13 @@ void debug_play_update(PlayState* play) {
do_warp(play, pending_warp); do_warp(play, pending_warp);
} }
u16 pending_set_time = recomp_get_pending_set_time(); u32 pending_set_time = recomp_get_pending_set_time();
if (pending_set_time != 0xFFFF) { if (pending_set_time != 0xFFFF) {
u8 hour = (pending_set_time >> 8) & 0xFF; u8 day = (pending_set_time >> 16) & 0xFF;
u8 minute = (pending_set_time >> 0) & 0xFF; u8 hour = (pending_set_time >> 8) & 0xFF;
u8 minute = (pending_set_time >> 0) & 0xFF;
gSaveContext.save.time = CLOCK_TIME(hour, minute); gSaveContext.save.time = CLOCK_TIME(hour, minute);
gSaveContext.save.day = day;
} }
} }

View File

@ -8,6 +8,6 @@ DECLARE_FUNC(void, recomp_exit);
DECLARE_FUNC(void, recomp_handle_quicksave_actions, OSMesgQueue* enter_mq, OSMesgQueue* exit_mq); DECLARE_FUNC(void, recomp_handle_quicksave_actions, OSMesgQueue* enter_mq, OSMesgQueue* exit_mq);
DECLARE_FUNC(void, recomp_handle_quicksave_actions_main, OSMesgQueue* enter_mq, OSMesgQueue* exit_mq); DECLARE_FUNC(void, recomp_handle_quicksave_actions_main, OSMesgQueue* enter_mq, OSMesgQueue* exit_mq);
DECLARE_FUNC(u16, recomp_get_pending_warp); DECLARE_FUNC(u16, recomp_get_pending_warp);
DECLARE_FUNC(u16, recomp_get_pending_set_time); DECLARE_FUNC(u32, recomp_get_pending_set_time);
#endif #endif

View File

@ -4,7 +4,7 @@
#include "../patches/input.h" #include "../patches/input.h"
std::atomic<uint16_t> pending_warp = 0xFFFF; std::atomic<uint16_t> pending_warp = 0xFFFF;
std::atomic<uint16_t> pending_set_time = 0xFFFF; std::atomic<uint32_t> pending_set_time = 0xFFFF;
void recomp::do_warp(int area, int scene, int entrance) { void recomp::do_warp(int area, int scene, int entrance) {
const recomp::SceneWarps game_scene = recomp::game_warps[area].scenes[scene]; const recomp::SceneWarps game_scene = recomp::game_warps[area].scenes[scene];
@ -17,11 +17,11 @@ extern "C" void recomp_get_pending_warp(uint8_t* rdram, recomp_context* ctx) {
_return(ctx, pending_warp.exchange(0xFFFF)); _return(ctx, pending_warp.exchange(0xFFFF));
} }
void recomp::set_time(uint8_t hour, uint8_t minute) { void recomp::set_time(uint8_t day, uint8_t hour, uint8_t minute) {
pending_set_time.store((uint16_t(hour) << 8) | minute); pending_set_time.store((day << 16) | (uint16_t(hour) << 8) | minute);
} }
extern "C" void recomp_get_pending_set_time(uint8_t* rdram, recomp_context* ctx) { extern "C" void recomp_get_pending_set_time(uint8_t* rdram, recomp_context* ctx) {
// Return the current set time value and reset it. // Return the current set time value and reset it.
_return(ctx, pending_set_time.exchange(0xFFFF)); _return(ctx, pending_set_time.exchange(0xFFFF));
} }

View File

@ -199,8 +199,9 @@ struct DebugContext {
int area_index = 0; int area_index = 0;
int scene_index = 0; int scene_index = 0;
int entrance_index = 0; int entrance_index = 0;
uint8_t set_time_hour = 0; int set_time_day = 1;
uint8_t set_time_minute = 0; int set_time_hour = 12;
int set_time_minute = 0;
bool debug_enabled = false; bool debug_enabled = false;
DebugContext() { DebugContext() {
@ -296,7 +297,7 @@ public:
recomp::register_event(listener, "set_time", recomp::register_event(listener, "set_time",
[](const std::string& param, Rml::Event& event) { [](const std::string& param, Rml::Event& event) {
recomp::set_time(debug_context.set_time_hour, debug_context.set_time_minute); recomp::set_time(debug_context.set_time_day, debug_context.set_time_hour, debug_context.set_time_minute);
}); });
} }
@ -627,6 +628,10 @@ public:
constructor.Bind("scene_names", &debug_context.scene_names); constructor.Bind("scene_names", &debug_context.scene_names);
constructor.Bind("entrance_names", &debug_context.entrance_names); constructor.Bind("entrance_names", &debug_context.entrance_names);
constructor.Bind("debug_time_day", &debug_context.set_time_day);
constructor.Bind("debug_time_hour", &debug_context.set_time_hour);
constructor.Bind("debug_time_minute", &debug_context.set_time_minute);
debug_context.model_handle = constructor.GetModelHandle(); debug_context.model_handle = constructor.GetModelHandle();
} }