Merge pull request #5755 from spacek531/seconds-to-ms

calculate ticks from ms instead of seconds
This commit is contained in:
Ted John 2017-07-07 18:11:42 +01:00 committed by GitHub
commit 22a936b4a9
9 changed files with 40 additions and 24 deletions

View File

@ -11,8 +11,8 @@ include(CheckCXXCompilerFlag)
set(ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}")
set(CMAKE_MACOSX_RPATH 1)
set(TITLE_SEQUENCE_URL "https://github.com/OpenRCT2/title-sequences/releases/download/v0.0.5/title-sequence-v0.0.5.zip")
set(TITLE_SEQUENCE_SHA1 "79ffb2585d12abcbfce205d7696e3472a504b005")
set(TITLE_SEQUENCE_URL "https://github.com/OpenRCT2/title-sequences/releases/download/v0.1.0/title-sequence-v0.1.0.zip")
set(TITLE_SEQUENCE_SHA1 "b587d83de508d0b104d14c599b76f8565900fce0")
option(FORCE32 "Force 32-bit build. It will add `-m32` to compiler flags.")
option(WITH_TESTS "Build tests")

View File

@ -2871,7 +2871,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "version=\"0.0.5\"\nzipname=\"title-sequence-v$version.zip\"\nliburl=\"https://github.com/OpenRCT2/title-sequences/releases/download/v$version/$zipname\"\n\n[[ ! -d \"${SRCROOT}/data/title\" || ! -e \"${SRCROOT}/sequencesversion\" || $(head -n 1 \"${SRCROOT}/sequencesversion\") != $version ]]\noutdated=$?\n\nif [[ $outdated -eq 0 ]]; then\nif [[ -d \"${SRCROOT}/data/title\" ]]; then rm -r \"${SRCROOT}/data/title\"; fi\nmkdir -p \"${SRCROOT}/data/title\"\n\ncurl -L -o \"${SRCROOT}/data/title/$zipname\" \"$liburl\"\nunzip -uaq -d \"${SRCROOT}/data/title\" \"${SRCROOT}/data/title/$zipname\"\nrm \"${SRCROOT}/data/title/$zipname\"\n\necho $version > \"${SRCROOT}/sequencesversion\"\nfi";
shellScript = "version=\"0.1.0\"\nzipname=\"title-sequence-v$version.zip\"\nliburl=\"https://github.com/OpenRCT2/title-sequences/releases/download/v$version/$zipname\"\n\n[[ ! -d \"${SRCROOT}/data/title\" || ! -e \"${SRCROOT}/sequencesversion\" || $(head -n 1 \"${SRCROOT}/sequencesversion\") != $version ]]\noutdated=$?\n\nif [[ $outdated -eq 0 ]]; then\nif [[ -d \"${SRCROOT}/data/title\" ]]; then rm -r \"${SRCROOT}/data/title\"; fi\nmkdir -p \"${SRCROOT}/data/title\"\n\ncurl -L -o \"${SRCROOT}/data/title/$zipname\" \"$liburl\"\nunzip -uaq -d \"${SRCROOT}/data/title\" \"${SRCROOT}/data/title/$zipname\"\nrm \"${SRCROOT}/data/title/$zipname\"\n\necho $version > \"${SRCROOT}/sequencesversion\"\nfi";
};
D4EC012A1C25532B00DAFE69 /* Setup AppIcon */ = {
isa = PBXShellScriptBuildPhase;

View File

@ -3762,13 +3762,13 @@ STR_5420 :Rotate{MOVE_X}{87}{COMMA16}
STR_5421 :Zoom
STR_5422 :Zoom{MOVE_X}{87}{COMMA16}
STR_5423 :Wait
STR_5424 :Wait{MOVE_X}{87}{COMMA16}
STR_5424 :Wait{MOVE_X}{87}{UINT16}
STR_5425 :Restart
STR_5426 :End
STR_5427 :Coordinates:
STR_5428 :Anticlockwise rotations:
STR_5429 :Zoom level:
STR_5430 :Seconds to wait:
STR_5430 :Milliseconds to wait:
STR_5431 :Save to load:
STR_5432 :Command:
STR_5433 :Title Sequences

View File

@ -68,8 +68,8 @@
<GtestVersion>1.8.0</GtestVersion>
<GtestUrl>https://github.com/google/googletest/archive/release-1.8.0.zip</GtestUrl>
<GtestSha1>667f873ab7a4d246062565fad32fb6d8e203ee73</GtestSha1>
<TitleSequencesUrl>https://github.com/OpenRCT2/title-sequences/releases/download/v0.0.5/title-sequence-v0.0.5.zip</TitleSequencesUrl>
<TitleSequencesSha1>79ffb2585d12abcbfce205d7696e3472a504b005</TitleSequencesSha1>
<TitleSequencesUrl>https://github.com/OpenRCT2/title-sequences/releases/download/v0.1.0/title-sequence-v0.1.0.zip</TitleSequencesUrl>
<TitleSequencesSha1>b587d83de508d0b104d14c599b76f8565900fce0</TitleSequencesSha1>
</PropertyGroup>
<ItemGroup>

View File

@ -446,7 +446,7 @@ static std::vector<TitleCommand> LegacyScriptRead(utf8 * script, size_t scriptLe
else if (_stricmp(token, "WAIT") == 0)
{
command.Type = TITLE_SCRIPT_WAIT;
command.Seconds = atoi(part1) & 0xFF;
command.Milliseconds = atoi(part1) & 0xFFFF;
}
else if (_stricmp(token, "RESTART") == 0)
{
@ -595,7 +595,7 @@ static utf8 * LegacyScriptWrite(TitleSequence * seq)
sb.Append(buffer);
break;
case TITLE_SCRIPT_WAIT:
String::Format(buffer, sizeof(buffer), "WAIT %u", command->Seconds);
String::Format(buffer, sizeof(buffer), "WAIT %u", command->Milliseconds);
sb.Append(buffer);
break;
case TITLE_SCRIPT_RESTART:

View File

@ -31,7 +31,7 @@ typedef struct TitleCommand
uint8 Rotations; // ROTATE (counter-clockwise)
uint8 Zoom; // ZOOM
uint8 Speed; // SPEED
uint8 Seconds; // WAIT
uint16 Milliseconds; // WAIT
};
} TitleCommand;

View File

@ -247,7 +247,8 @@ private:
_waitCounter = 1;
break;
case TITLE_SCRIPT_WAIT:
_waitCounter = command->Seconds * UPDATE_FPS;
// The waitCounter is measured in 25-ms game ticks. Previously it was seconds * 40 ticks/second, now it is ms / 25 ms/tick
_waitCounter = Math::Max<sint32>(1, command->Milliseconds / UPDATE_TIME_MS);
break;
case TITLE_SCRIPT_LOADMM:
{

View File

@ -30,7 +30,8 @@
#include "dropdown.h"
typedef struct TITLE_COMMAND_ORDER {
uint8 command;
// originally a uint8, but the new millisecond wait times require a uint16.
uint16 command;
rct_string_id nameStringId;
rct_string_id descStringId;
} TITLE_COMMAND_ORDER;
@ -242,9 +243,11 @@ void window_title_command_editor_open(TitleSequence * sequence, sint32 index, bo
break;
case TITLE_SCRIPT_ROTATE:
case TITLE_SCRIPT_ZOOM:
case TITLE_SCRIPT_WAIT:
snprintf(textbox1Buffer, BUF_SIZE, "%d", command.Rotations);
break;
case TITLE_SCRIPT_WAIT:
snprintf(textbox1Buffer, BUF_SIZE, "%d", command.Milliseconds);
break;
}
}
@ -256,7 +259,13 @@ static void window_title_command_editor_mouseup(rct_window *w, rct_widgetindex w
window_close(w);
break;
case WIDX_TEXTBOX_FULL:
window_start_textbox(w, widgetIndex, STR_STRING, textbox1Buffer, 4);
// The only commands that use TEXTBOX_FULL currently are Wait, Rotate, and Zoom. Rotate and Zoom have single-digit maximum values, while Wait has 5-digit maximum values.
if (command.Type == TITLE_SCRIPT_WAIT) {
window_start_textbox(w, widgetIndex, STR_STRING, textbox1Buffer, 6);
}
else {
window_start_textbox(w, widgetIndex, STR_STRING, textbox1Buffer, 2);
}
break;
case WIDX_TEXTBOX_X:
window_start_textbox(w, widgetIndex, STR_STRING, textbox1Buffer, 4);
@ -402,8 +411,8 @@ static void window_title_command_editor_dropdown(rct_window *w, rct_widgetindex
command.Speed = 1;
break;
case TITLE_SCRIPT_WAIT:
command.Seconds = 10;
snprintf(textbox1Buffer, BUF_SIZE, "%d", command.Seconds);
command.Milliseconds = 10000;
snprintf(textbox1Buffer, BUF_SIZE, "%d", command.Milliseconds);
break;
case TITLE_SCRIPT_LOAD:
command.SaveIndex = 0;
@ -438,20 +447,26 @@ static void window_title_command_editor_textinput(rct_window * w, rct_widgetinde
char * end;
sint32 value = strtol(widgetIndex != WIDX_TEXTBOX_Y ? textbox1Buffer : textbox2Buffer, &end, 10);
if (value < 0) value = 0;
if (value > 255) value = 255;
// The Wait command is the only one with acceptable values greater than 255.
if (value > 255 && command.Type != TITLE_SCRIPT_WAIT) value = 255;
switch (widgetIndex) {
case WIDX_TEXTBOX_FULL:
if (text == NULL) {
if (*end == '\0') {
if (command.Type == TITLE_SCRIPT_ROTATE || command.Type == TITLE_SCRIPT_ZOOM) {
if (command.Type == TITLE_SCRIPT_WAIT) {
if (value < 100) value = 100;
if (value > 65000) value = 65000;
command.Milliseconds = (uint16)value;
snprintf(textbox1Buffer, BUF_SIZE, "%d", command.Milliseconds);
}
else {
// Both Rotate and Zoom have a maximum value of 3, but Rotate has a min value of 1 not 0.
if (value > 3) value = 3;
if (value < 1 && command.Type == TITLE_SCRIPT_ROTATE) value = 1;
command.Rotations = (uint8)value;
snprintf(textbox1Buffer, BUF_SIZE, "%d", command.Rotations);
}
else if (command.Type == TITLE_SCRIPT_WAIT) {
if (value < 1) value = 1;
}
command.Rotations = (uint8)value;
}
snprintf(textbox1Buffer, BUF_SIZE, "%d", command.Rotations);
window_invalidate(w);
} else {
safe_strcpy(textbox1Buffer, text, sizeof(textbox1Buffer));

View File

@ -891,7 +891,7 @@ static void window_title_editor_scrollpaint_commands(rct_window *w, rct_drawpixe
break;
case TITLE_SCRIPT_WAIT:
commandName = STR_TITLE_EDITOR_COMMAND_WAIT;
set_format_arg(0, uint16, command->Seconds);
set_format_arg(0, uint16, command->Milliseconds);
break;
case TITLE_SCRIPT_RESTART:
commandName = STR_TITLE_EDITOR_RESTART;