Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Enhancement] MM3D style clock #713

Merged
merged 16 commits into from
Aug 18, 2024

Conversation

Hoeloe
Copy link
Contributor

@Hoeloe Hoeloe commented Jun 25, 2024

Adds a new 3-day clock mode that mimics the style of the MM3D clock as an option in the graphics section of the enhancements menu, alongside the text-based clock. All assets are original and hand drawn.

3ds clock 1
3ds clock 2
3ds clock 3

Build Artifacts

Hoeloe added 15 commits June 24, 2024 16:28
Just trying to get basic drawing to work before actually working on the system proper.
basic functionality now complete
fully implemented v1 of the 3ds clock
removed some unused code and added some slightly better comments
formatted using clang
missing line added that caused one part of the hud to not respect the hud editor
final hours clock now lerps between yellow and red like in MM3D
delayed moving the marker backwards by one frame if time steps backwards to avoid skipping around on day transitions
@Hoeloe Hoeloe changed the title MM3D style clock enhancement [Enhancement] MM3D style clock Jun 27, 2024
Copy link
Contributor

@Archez Archez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! Overall, this is a really clean and isolated implementation for the clock display. In my play testing I didn't notice anything strange about the behavior. Great job!

I've left a couple suggestions/questions below, mostly just little nits and opportunities to help with code readability through comments and variable names.


// This is a safety measure to delay skipping the arrow marker back a day on the frame before the
// day changes by just checking if time went backwards
if (sPreviousTimeCheck != -1 && sPreviousTimeCheck > 259200 - timeUntilCrash) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you have 259200 in a few spots and I believe is the amount of seconds in 3 days. You could move this to a define for easier readability like:

#define SECONDS_IN_THREE_DAYS 3 * 24 * 60 * 60

u16 finalTimerPos = posX - finalTimerSpacing * 4 - finalTimerSpacing / 2;
s16 i;

s32 percentToCrash = std::min(std::max((timeUntilCrash * 255) / 21600, 0), 255);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here, 21600 looks like seconds in 6 hours
SECONDS_IN_SIX_HOURS 6 * 60 * 60

Comment on lines +200 to +204
s32 finalHoursOffset = 10;
s32 finalHoursModifier = 2;
if (sFinalHoursIntro < finalHoursOffset * finalHoursModifier) {
sFinalHoursIntro++;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like these values and logic are how you control the animation of the final hours sliding in. I think to help with readability you could add some comments explaining these variables and the exact intent.

Comment on lines 131 to 134
s32 currentTime = (s32)TIME_TO_MINUTES_F(gSaveContext.save.time) - 360;
if (currentTime < 0) {
currentTime += 1440;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this block normalizing the time to the games 6am-6am range?
Looks like the constants are minutes in 6 hours and minutes in 24 hours respectively.

But actually I don't see currenTime being used anywhere, so this code could be dropped if its not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these were from an earlier version of the clock and somehow managed to sneakily avoid being deleted. I should be fine to get rid of them.

sPreviousTimeCheck = 259200 - timeUntilCrash;
}

s32 timeoffset = std::max(std::min(3 * 48 - (timeUntilCrash * 3 * 48) / 259200, 3 * 48), 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like 48 is used in some of the position calculations and represents the width of each day section. I'd recommend using a define for this as well so that relationship is captured clearly.

// Digital time
u16 timerSpacing = 6;

if (curTensHours > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on always showing the leading 0 when in 24 hour time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding that because I have no strong preference and it makes sense.

Comment on lines 48 to 52
static s16 sThreeDayClockAlpha = 255;

static s32 sPreviousTimeCheck = -1;

static s32 sFinalHoursIntro = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either move these static vars up to the file level scope, or down into the actual hook body scope, since they are not used anywhere else.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chose to move these down in scope because I prefer to keep things as tightly scoped as possible where appropriate.

OVERLAY_DISP = Gfx_DrawTexRectIA8(OVERLAY_DISP, (TexturePtr)gThreeDayClock3DSFillTex, 48, 12,
posX + 24, posY, 48, 12, 1 << 10, 1 << 10);

gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 200, 0, 0, sThreeDayClockAlpha);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this color set down, closer to where the actual texture that uses it gets drawn.

…made 24-hour clock setting always use 4 digits. added more comments
Copy link
Contributor

@Archez Archez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making those changes, looks good to me now

Copy link
Contributor

@inspectredc inspectredc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, all looks good to me too!

@Archez Archez merged commit b0ca99f into HarbourMasters:develop Aug 18, 2024
5 checks passed
mckinlee pushed a commit to mckinlee/2ship2harkinian that referenced this pull request Oct 4, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants