forked from rosebudai/OpenRCT2-Web
Merge branch 'utf8' into develop
This commit is contained in:
commit
36b579ad66
65 files changed
+23929
-1386
No files matched your search
@@ -9,7 +9,7 @@ if [[ ! -d build ]]; then
|
||||
mkdir -p build
|
||||
fi
|
||||
|
||||
libversion=1
|
||||
libversion=2
|
||||
libVFile="./libversion"
|
||||
libdir="./lib"
|
||||
currentversion=0
|
||||
|
||||
@@ -3821,3 +3821,5 @@ STR_5481 :Themes
|
||||
STR_5482 :{WINDOW_COLOUR_2}Time since last inspection: {BLACK}1 minute
|
||||
STR_5483 :{BLACK}({COMMA16} weeks remaining)
|
||||
STR_5484 :{BLACK}({COMMA16} week remaining)
|
||||
STR_5485 :{SMALLFONT}{STRING}
|
||||
STR_5486 :{BLACK}{COMMA16}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#init
|
||||
$libversion = 1
|
||||
$libversion = 2
|
||||
$path = Split-Path $Script:MyInvocation.MyCommand.Path
|
||||
$zip = $path+'\orctlibs.zip'
|
||||
$libs = $path+'\lib'
|
||||
|
||||
@@ -112,6 +112,7 @@
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="..\..\data\language\chinese_traditional.txt" />
|
||||
<Text Include="..\..\data\language\dutch.txt" />
|
||||
<Text Include="..\..\data\language\english_uk.txt" />
|
||||
<Text Include="..\..\data\language\english_us.txt" />
|
||||
|
||||
@@ -37,5 +37,8 @@
|
||||
<Text Include="..\..\data\language\swedish.txt">
|
||||
<Filter>Resource Files\Language</Filter>
|
||||
</Text>
|
||||
<Text Include="..\..\data\language\chinese_traditional.txt">
|
||||
<Filter>Resource Files\Language</Filter>
|
||||
</Text>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -55,20 +55,20 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(SolutionDir)..\build\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\obj\$(ProjectName)\$(Configuration)\</IntDir>
|
||||
<IncludePath>..\..\lib\libcurl\include;..\..\lib\jansson;..\..\lib\cutest\CuTest.h;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>..\..\lib\libcurl\lib;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>..\..\lib\libcurl\include;..\..\lib\jansson;..\..\lib\cutest\CuTest.h;..\..\lib\SDL2_ttf\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>..\..\lib\libcurl\lib;..\..\lib\SDL2_ttf\lib\x86;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)..\build\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\obj\$(ProjectName)\$(Configuration)\</IntDir>
|
||||
<IncludePath>..\..\lib\libcurl\include;..\..\lib\jansson;..\..\lib\cutest\CuTest.h;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>..\..\lib\libcurl\lib;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>..\..\lib\libcurl\include;..\..\lib\jansson;..\..\lib\cutest\CuTest.h;..\..\lib\SDL2_ttf\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>..\..\lib\libcurl\lib;..\..\lib\SDL2_ttf\lib\x86;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release with Tests|Win32'">
|
||||
<OutDir>$(SolutionDir)..\build\Release\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\obj\$(ProjectName)\Release\</IntDir>
|
||||
<IncludePath>..\..\lib\libcurl\include;..\..\lib\jansson;..\..\lib\cutest\CuTest.h;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>..\..\lib\libcurl\lib;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>..\..\lib\libcurl\include;..\..\lib\jansson;..\..\lib\cutest\CuTest.h;..\..\lib\SDL2_ttf\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>..\..\lib\libcurl\lib;..\..\lib\SDL2_ttf\lib\x86;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@@ -83,7 +83,7 @@
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalDependencies>libcurl.lib;Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>libcurl.lib;Ws2_32.lib;SDL2_ttf.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Lib>
|
||||
<PreBuildEvent>
|
||||
<Command>Powershell -NonInteractive -ExecutionPolicy "ByPass" -File "$(ProjectDir)../../pre-build.ps1"</Command>
|
||||
@@ -108,7 +108,7 @@
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalDependencies>libcurl.lib;Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>libcurl.lib;Ws2_32.lib;SDL2_ttf.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Lib>
|
||||
<PreBuildEvent>
|
||||
<Command>Powershell -NonInteractive -ExecutionPolicy "ByPass" -File "$(ProjectDir)../../pre-build.ps1"</Command>
|
||||
@@ -133,7 +133,7 @@
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalDependencies>libcurl.lib;Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>libcurl.lib;Ws2_32.lib;SDL2_ttf.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Lib>
|
||||
<PreBuildEvent>
|
||||
<Command>Powershell -NonInteractive -ExecutionPolicy "ByPass" -File "$(ProjectDir)../../pre-build.ps1"</Command>
|
||||
|
||||
@@ -33,9 +33,11 @@
|
||||
<ClCompile Include="..\src\cursors.c" />
|
||||
<ClCompile Include="..\src\diagnostic.c" />
|
||||
<ClCompile Include="..\src\drawing\drawing.c" />
|
||||
<ClCompile Include="..\src\drawing\font.c" />
|
||||
<ClCompile Include="..\src\drawing\line.c" />
|
||||
<ClCompile Include="..\src\drawing\rain.c" />
|
||||
<ClCompile Include="..\src\drawing\rect.c" />
|
||||
<ClCompile Include="..\src\drawing\scrolling_text.c" />
|
||||
<ClCompile Include="..\src\drawing\sprite.c" />
|
||||
<ClCompile Include="..\src\drawing\string.c" />
|
||||
<ClCompile Include="..\src\editor.c" />
|
||||
@@ -58,12 +60,14 @@
|
||||
<ClCompile Include="..\src\interface\widget.c" />
|
||||
<ClCompile Include="..\src\interface\window.c" />
|
||||
<ClCompile Include="..\src\intro.c" />
|
||||
<ClCompile Include="..\src\localisation\convert.c" />
|
||||
<ClCompile Include="..\src\localisation\currency.c" />
|
||||
<ClCompile Include="..\src\localisation\date.c" />
|
||||
<ClCompile Include="..\src\localisation\language.c" />
|
||||
<ClCompile Include="..\src\localisation\localisation.c" />
|
||||
<ClCompile Include="..\src\localisation\real_names.c" />
|
||||
<ClCompile Include="..\src\localisation\user.c" />
|
||||
<ClCompile Include="..\src\localisation\utf8.c" />
|
||||
<ClCompile Include="..\src\management\award.c" />
|
||||
<ClCompile Include="..\src\management\finance.c" />
|
||||
<ClCompile Include="..\src\management\marketing.c" />
|
||||
@@ -193,6 +197,7 @@
|
||||
<ClInclude Include="..\src\cursors.h" />
|
||||
<ClInclude Include="..\src\diagnostic.h" />
|
||||
<ClInclude Include="..\src\drawing\drawing.h" />
|
||||
<ClInclude Include="..\src\drawing\font.h" />
|
||||
<ClInclude Include="..\src\editor.h" />
|
||||
<ClInclude Include="..\src\game.h" />
|
||||
<ClInclude Include="..\src\hook.h" />
|
||||
@@ -310,13 +315,13 @@
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<IncludePath>$(SolutionDir)..\lib;$(SolutionDir)..\lib\libspeex;$(SolutionDir)..\lib\sdl\include;$(SolutionDir)..\lib\libcurl\include;$(SolutionDir)..\lib\jansson;$(SolutionDir)..\lib\cutest;$(IncludePath)</IncludePath>
|
||||
<IncludePath>$(SolutionDir)..\lib;$(SolutionDir)..\lib\libspeex;$(SolutionDir)..\lib\sdl\include;$(SolutionDir)..\lib\libcurl\include;$(SolutionDir)..\lib\jansson;$(SolutionDir)..\lib\cutest;$(SolutionDir)..\lib\SDL2_ttf\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(SolutionDir)..\lib\sdl\lib\x86;$(SolutionDir)..\lib\libcurl\lib;$(LibraryPath)</LibraryPath>
|
||||
<OutDir>$(SolutionDir)..\build\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\obj\$(ProjectName)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<IncludePath>$(SolutionDir)..\lib;$(SolutionDir)..\lib\libspeex;$(SolutionDir)..\lib\sdl\include;$(SolutionDir)..\lib\libcurl\include;$(SolutionDir)..\lib\jansson;$(SolutionDir)..\lib\cutest;$(IncludePath)</IncludePath>
|
||||
<IncludePath>$(SolutionDir)..\lib;$(SolutionDir)..\lib\libspeex;$(SolutionDir)..\lib\sdl\include;$(SolutionDir)..\lib\libcurl\include;$(SolutionDir)..\lib\jansson;$(SolutionDir)..\lib\cutest;$(SolutionDir)..\lib\SDL2_ttf\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(SolutionDir)..\lib\sdl\lib\x86;$(SolutionDir)..\lib\libcurl\lib;$(LibraryPath)</LibraryPath>
|
||||
<OutDir>$(SolutionDir)..\build\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\obj\$(ProjectName)\$(Configuration)\</IntDir>
|
||||
@@ -324,7 +329,7 @@
|
||||
</CustomBuildBeforeTargets>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release with Tests|Win32'">
|
||||
<IncludePath>$(SolutionDir)..\lib;$(SolutionDir)..\lib\libspeex;$(SolutionDir)..\lib\sdl\include;$(SolutionDir)..\lib\libcurl\include;$(SolutionDir)..\lib\jansson;$(SolutionDir)..\lib\cutest;$(IncludePath)</IncludePath>
|
||||
<IncludePath>$(SolutionDir)..\lib;$(SolutionDir)..\lib\libspeex;$(SolutionDir)..\lib\sdl\include;$(SolutionDir)..\lib\libcurl\include;$(SolutionDir)..\lib\jansson;$(SolutionDir)..\lib\cutest;$(SolutionDir)..\lib\SDL2_ttf\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(SolutionDir)..\lib\sdl\lib\x86;$(SolutionDir)..\lib\libcurl\lib;$(LibraryPath)</LibraryPath>
|
||||
<OutDir>$(SolutionDir)..\build\Release\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\obj\$(ProjectName)\Release\</IntDir>
|
||||
|
||||
@@ -495,6 +495,18 @@
|
||||
<ClCompile Include="..\src\cheats.c">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\localisation\convert.c">
|
||||
<Filter>Source\Localisation</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\drawing\scrolling_text.c">
|
||||
<Filter>Source\Drawing</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\drawing\font.c">
|
||||
<Filter>Source\Drawing</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\localisation\utf8.c">
|
||||
<Filter>Source\Localisation</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\src\management\award.h">
|
||||
@@ -725,5 +737,8 @@
|
||||
<ClInclude Include="..\src\cheats.h">
|
||||
<Filter>Source</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\drawing\font.h">
|
||||
<Filter>Source\Drawing</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -21,5 +21,7 @@
|
||||
<LocalDebuggerCommand>$(TargetDir)\openrct2.exe</LocalDebuggerCommand>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
<LocalDebuggerWorkingDirectory>$(TargetDir)</LocalDebuggerWorkingDirectory>
|
||||
<LocalDebuggerCommandArguments>
|
||||
</LocalDebuggerCommandArguments>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
+5
-4
@@ -138,6 +138,7 @@ config_enum_definition _languageEnum[] = {
|
||||
{ "sv-SE", LANGUAGE_SWEDISH },
|
||||
{ "it-IT", LANGUAGE_ITALIAN },
|
||||
{ "pt-BR", LANGUAGE_PORTUGUESE_BR },
|
||||
{ "zh-Hant", LANGUAGE_CHINESE_TRADITIONAL },
|
||||
END_OF_ENUM
|
||||
};
|
||||
|
||||
@@ -704,13 +705,13 @@ static config_line *_configLines = NULL;
|
||||
* @param resultPath Pointer to where the absolute path of the RCT2 installation directory will be copied to.
|
||||
* @returns 1 if successful, otherwise 0.
|
||||
*/
|
||||
static bool config_find_rct2_path(char *resultPath)
|
||||
static bool config_find_rct2_path(utf8 *resultPath)
|
||||
{
|
||||
int i;
|
||||
|
||||
log_verbose("searching common installation locations.");
|
||||
|
||||
const char *searchLocations[] = {
|
||||
const utf8 *searchLocations[] = {
|
||||
"C:\\Program Files\\Infogrames\\RollerCoaster Tycoon 2",
|
||||
"C:\\Program Files (x86)\\Infogrames\\RollerCoaster Tycoon 2",
|
||||
"C:\\Program Files\\Infogrames Interactive\\RollerCoaster Tycoon 2",
|
||||
@@ -733,8 +734,8 @@ static bool config_find_rct2_path(char *resultPath)
|
||||
|
||||
bool config_find_or_browse_install_directory()
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
char *installPath;
|
||||
utf8 path[MAX_PATH];
|
||||
utf8 *installPath;
|
||||
|
||||
if (config_find_rct2_path(path)) {
|
||||
SafeFree(gConfigGeneral.game_path);
|
||||
|
||||
+10
-2
@@ -22,6 +22,7 @@
|
||||
#define _DRAWING_H_
|
||||
|
||||
#include "../common.h"
|
||||
#include "font.h"
|
||||
|
||||
// Size: 0x10
|
||||
typedef struct {
|
||||
@@ -113,7 +114,6 @@ void gfx_draw_sprite(rct_drawpixelinfo *dpi, int image_id, int x, int y, uint32
|
||||
void gfx_draw_sprite_palette_set(rct_drawpixelinfo *dpi, int image_id, int x, int y, uint8* palette_pointer, uint8* unknown_pointer);
|
||||
|
||||
// string
|
||||
void gfx_load_character_widths();
|
||||
int clip_text(char *buffer, int width);
|
||||
int gfx_wrap_string(char* buffer, int width, int* num_lines, int* font_height);
|
||||
int gfx_get_string_width(char *buffer);
|
||||
@@ -132,7 +132,11 @@ void draw_string_centred_raw(rct_drawpixelinfo *dpi, int x, int y, int numLines,
|
||||
void gfx_draw_string_right(rct_drawpixelinfo *dpi, int format, void *args, int colour, int x, int y);
|
||||
void draw_string_right_underline(rct_drawpixelinfo *dpi, int format, void *args, int colour, int x, int y);
|
||||
int string_get_height_raw(char *buffer);
|
||||
void sub_6C1F57(rct_drawpixelinfo *dpi, int x, int y, int width, int colour, rct_string_id format, void *args, int ticks);
|
||||
void gfx_draw_string_centred_wrapped_partial(rct_drawpixelinfo *dpi, int x, int y, int width, int colour, rct_string_id format, void *args, int ticks);
|
||||
void gfx_draw_string_with_y_offsets(rct_drawpixelinfo *dpi, utf8 *text, int colour, int x, int y, const sint8 *yOffsets);
|
||||
|
||||
bool ttf_initialise();
|
||||
void ttf_dispose();
|
||||
|
||||
// rain
|
||||
void update_rain_animation();
|
||||
@@ -141,4 +145,8 @@ void redraw_rain();
|
||||
// unknown
|
||||
void sub_681DE2(rct_drawpixelinfo *dpi, int x, int y, int image1, int image2);
|
||||
|
||||
// scrolling text
|
||||
void scrolling_text_initialise_bitmaps();
|
||||
int scrolling_text_setup(rct_string_id stringId, uint16 scroll, uint16 scrollingMode);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,128 @@
|
||||
#include "../addresses.h"
|
||||
#include "../localisation/localisation.h"
|
||||
#include "../sprites.h"
|
||||
#include "drawing.h"
|
||||
#include "font.h"
|
||||
|
||||
static const int SpriteFontLineHeight[] = { 6, 10, 10, 18 };
|
||||
|
||||
static uint8 *_spriteFontCharacterWidths = (uint8*)RCT2_ADDRESS_FONT_CHAR_WIDTH;
|
||||
|
||||
TTFFontSetDescriptor *gCurrentTTFFontSet;
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006C19AC
|
||||
*/
|
||||
void font_sprite_initialise_characters()
|
||||
{
|
||||
uint8* pCharacterWidth = _spriteFontCharacterWidths;
|
||||
for (int fontSize = 0; fontSize < FONT_SIZE_COUNT; fontSize++) {
|
||||
int glyphOffset = fontSize * FONT_SPRITE_GLYPH_COUNT;
|
||||
for (uint8 glyphIndex = 0; glyphIndex < FONT_SPRITE_GLYPH_COUNT; glyphIndex++) {
|
||||
rct_g1_element g1 = g1Elements[glyphIndex + SPR_CHAR_START + glyphOffset];
|
||||
|
||||
int width = fontSize == FONT_SIZE_BIG ? g1.width + 1 : g1.width - 1;
|
||||
if (glyphIndex >= (FORMAT_ARGUMENT_CODE_START - 32) && glyphIndex < (FORMAT_COLOUR_CODE_END - 32)) {
|
||||
width = 0;
|
||||
}
|
||||
*pCharacterWidth++ = (uint8)width;
|
||||
}
|
||||
}
|
||||
|
||||
scrolling_text_initialise_bitmaps();
|
||||
|
||||
for (int i = 0; i < 32; i++) {
|
||||
rct_g1_element* g1 = &g1Elements[0x606 + i];
|
||||
uint8* unknown_pointer = RCT2_ADDRESS(0x009C3852, uint8) + 0xA12 * i;
|
||||
g1->offset = unknown_pointer;
|
||||
g1->width = 64;
|
||||
g1->height = 40;
|
||||
*((uint16*)unknown_pointer) = 0xFFFF;
|
||||
*((uint32*)(unknown_pointer + 0x0E)) = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int font_sprite_get_codepoint_offset(int codepoint)
|
||||
{
|
||||
switch (codepoint) {
|
||||
case FORMAT_ENDQUOTES: return 34 - 32;
|
||||
|
||||
case FORMAT_AMINUSCULE: return 159 - 32;
|
||||
case FORMAT_UP: return 160 - 32;
|
||||
case FORMAT_SYMBOL_i: return 160 - 32;
|
||||
case FORMAT_CENT: return 162 - 32;
|
||||
case FORMAT_POUND: return 163 - 32;
|
||||
|
||||
case FORMAT_YEN: return 165 - 32;
|
||||
|
||||
|
||||
|
||||
case FORMAT_COPYRIGHT: return 169 - 32;
|
||||
case FORMAT_DOWN: return 170 - 32;
|
||||
case FORMAT_LEFTGUILLEMET: return 171 - 32;
|
||||
case FORMAT_TICK: return 172 - 32;
|
||||
case FORMAT_CROSS: return 173 - 32;
|
||||
|
||||
case FORMAT_RIGHT: return 175 - 32;
|
||||
case FORMAT_DEGREE: return 176 - 32;
|
||||
case FORMAT_SYMBOL_RAILWAY: return 177 - 32;
|
||||
case FORMAT_SQUARED: return 178 - 32;
|
||||
|
||||
case FORMAT_OPENQUOTES: return 180 - 32;
|
||||
case FORMAT_EURO: return 181 - 32;
|
||||
case FORMAT_SYMBOL_ROAD: return 182 - 32;
|
||||
case FORMAT_SYMBOL_FLAG: return 183 - 32;
|
||||
case FORMAT_APPROX: return 184 - 32;
|
||||
case FORMAT_POWERNEGATIVEONE: return 185 - 32;
|
||||
case FORMAT_BULLET: return 186 - 32;
|
||||
case FORMAT_RIGHTGUILLEMET: return 187 - 32;
|
||||
case FORMAT_SMALLUP: return 188 - 32;
|
||||
case FORMAT_SMALLDOWN: return 189 - 32;
|
||||
case FORMAT_LEFT: return 190 - 32;
|
||||
case FORMAT_INVERTEDQUESTION: return 191 - 32;
|
||||
default:
|
||||
if (codepoint < 32 || codepoint >= 256) codepoint = '?';
|
||||
return codepoint - 32;
|
||||
}
|
||||
}
|
||||
|
||||
int font_sprite_get_codepoint_width(int fontSpriteBase, int codepoint)
|
||||
{
|
||||
return _spriteFontCharacterWidths[fontSpriteBase + font_sprite_get_codepoint_offset(codepoint)];
|
||||
}
|
||||
|
||||
int font_sprite_get_codepoint_sprite(int fontSpriteBase, int codepoint)
|
||||
{
|
||||
return SPR_CHAR_START + ((IMAGE_TYPE_USE_PALETTE << 28) | (fontSpriteBase + font_sprite_get_codepoint_offset(codepoint)));
|
||||
}
|
||||
|
||||
int font_get_size_from_sprite_base(uint16 spriteBase)
|
||||
{
|
||||
switch (spriteBase) {
|
||||
case FONT_SPRITE_BASE_TINY:
|
||||
return 0;
|
||||
case FONT_SPRITE_BASE_SMALL:
|
||||
return 1;
|
||||
default:
|
||||
case FONT_SPRITE_BASE_MEDIUM:
|
||||
return 2;
|
||||
case FONT_SPRITE_BASE_BIG:
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
int font_get_line_height(int fontSpriteBase)
|
||||
{
|
||||
int fontSize = font_get_size_from_sprite_base(fontSpriteBase);
|
||||
if (gUseTrueTypeFont) {
|
||||
return gCurrentTTFFontSet->size[fontSize].line_height;
|
||||
} else {
|
||||
return SpriteFontLineHeight[fontSize];
|
||||
}
|
||||
}
|
||||
|
||||
int font_get_line_height_small(int fontSpriteBase)
|
||||
{
|
||||
return font_get_line_height(fontSpriteBase) / 2;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#ifndef _DRAWING_FONT_H_
|
||||
#define _DRAWING_FONT_H_
|
||||
|
||||
#include <SDL_ttf.h>
|
||||
#include "../common.h"
|
||||
|
||||
enum {
|
||||
FONT_SIZE_TINY = 2,
|
||||
FONT_SIZE_SMALL = 0,
|
||||
FONT_SIZE_MEDIUM = 1,
|
||||
FONT_SIZE_BIG = 3,
|
||||
FONT_SIZE_COUNT = 4
|
||||
};
|
||||
|
||||
enum {
|
||||
FONT_SPRITE_GLYPH_COUNT = 224,
|
||||
|
||||
FONT_SPRITE_BASE_TINY = 448,
|
||||
FONT_SPRITE_BASE_SMALL = 0,
|
||||
FONT_SPRITE_BASE_MEDIUM = 224,
|
||||
FONT_SPRITE_BASE_BIG = 672
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
utf8 *filename;
|
||||
int ptSize;
|
||||
int offset_x;
|
||||
int offset_y;
|
||||
int line_height;
|
||||
TTF_Font *font;
|
||||
} TTFFontDescriptor;
|
||||
|
||||
typedef struct {
|
||||
TTFFontDescriptor size[FONT_SIZE_COUNT];
|
||||
} TTFFontSetDescriptor;
|
||||
|
||||
extern TTFFontSetDescriptor *gCurrentTTFFontSet;
|
||||
|
||||
void font_sprite_initialise_characters();
|
||||
int font_sprite_get_codepoint_offset(int codepoint);
|
||||
int font_sprite_get_codepoint_width(int fontSpriteBase, int codepoint);
|
||||
int font_sprite_get_codepoint_sprite(int fontSpriteBase, int codepoint);
|
||||
int font_get_size_from_sprite_base(uint16 spriteBase);
|
||||
int font_get_line_height(int fontSpriteBase);
|
||||
int font_get_line_height_small(int fontSpriteBase);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,279 @@
|
||||
#include <SDL_ttf.h>
|
||||
#include "../addresses.h"
|
||||
#include "../config.h"
|
||||
#include "../localisation/localisation.h"
|
||||
#include "drawing.h"
|
||||
|
||||
/* size: 0xA12 */
|
||||
typedef struct {
|
||||
rct_string_id string_id; // 0x00
|
||||
uint32 string_args_0; // 0x02
|
||||
uint32 string_args_1; // 0x06
|
||||
uint16 position; // 0x0A
|
||||
uint16 mode; // 0x0C
|
||||
uint32 id; // 0x0E
|
||||
uint8 bitmap[64 * 8 * 5]; // 0x12
|
||||
} rct_draw_scroll_text;
|
||||
|
||||
rct_draw_scroll_text *gDrawScrollTextList = RCT2_ADDRESS(RCT2_ADDRESS_DRAW_SCROLL_LIST, rct_draw_scroll_text);
|
||||
uint8 *gCharacterBitmaps = RCT2_ADDRESS(RCT2_ADDRESS_CHARACTER_BITMAP, uint8);
|
||||
|
||||
void scrolling_text_set_bitmap_for_sprite(utf8 *text, int scroll, uint8 *bitmap, sint16 *scrollPositionOffsets);
|
||||
void scrolling_text_set_bitmap_for_ttf(utf8 *text, int scroll, uint8 *bitmap, sint16 *scrollPositionOffsets);
|
||||
|
||||
void scrolling_text_initialise_bitmaps()
|
||||
{
|
||||
uint8 drawingSurface[64];
|
||||
rct_drawpixelinfo dpi = {
|
||||
.bits = (char*)&drawingSurface,
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = 8,
|
||||
.height = 8,
|
||||
.pitch = 0,
|
||||
.zoom_level = 0
|
||||
};
|
||||
|
||||
|
||||
for (int i = 0; i < 224; i++) {
|
||||
memset(drawingSurface, 0, sizeof(drawingSurface));
|
||||
gfx_draw_sprite(&dpi, i + 0x10D5, -1, 0, 0);
|
||||
|
||||
for (int x = 0; x < 8; x++) {
|
||||
uint8 val = 0;
|
||||
for (int y = 0; y < 8; y++) {
|
||||
val >>= 1;
|
||||
if (dpi.bits[x + y * 8] == 1) {
|
||||
val |= 0x80;
|
||||
}
|
||||
}
|
||||
gCharacterBitmaps[i * 8 + x] = val;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static uint8 *font_sprite_get_codepoint_bitmap(int codepoint)
|
||||
{
|
||||
return &gCharacterBitmaps[font_sprite_get_codepoint_offset(codepoint) * 8];
|
||||
}
|
||||
|
||||
|
||||
static int scrolling_text_get_matching_or_oldest(rct_string_id stringId, uint16 scroll, uint16 scrollingMode)
|
||||
{
|
||||
uint32 oldestId = 0xFFFFFFFF;
|
||||
int scrollIndex = -1;
|
||||
rct_draw_scroll_text* oldestScroll = NULL;
|
||||
for (int i = 0; i < 32; i++) {
|
||||
rct_draw_scroll_text *scrollText = &gDrawScrollTextList[i];
|
||||
if (oldestId >= scrollText->id) {
|
||||
oldestId = scrollText->id;
|
||||
scrollIndex = i;
|
||||
oldestScroll = scrollText;
|
||||
}
|
||||
|
||||
// If exact match return the matching index
|
||||
if (
|
||||
scrollText->string_id == stringId &&
|
||||
scrollText->string_args_0 == RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint32) &&
|
||||
scrollText->string_args_1 == RCT2_GLOBAL(0x13CE956, uint32) &&
|
||||
scrollText->position == scroll &&
|
||||
scrollText->mode == scrollingMode
|
||||
) {
|
||||
scrollText->id = RCT2_GLOBAL(RCT2_ADDRESS_DRAW_SCROLL_NEXT_ID, uint32);
|
||||
return i + 0x606;
|
||||
}
|
||||
}
|
||||
return scrollIndex;
|
||||
}
|
||||
|
||||
static uint8 scrolling_text_get_colour(uint32 character)
|
||||
{
|
||||
int edi = character & 0x7F;
|
||||
int offset = 0;
|
||||
if (character >= 0x80) offset = 2;
|
||||
return RCT2_ADDRESS(0x0141FC47, uint8)[offset + (edi * 8)];
|
||||
}
|
||||
|
||||
static void scrolling_text_format(utf8 *dst, rct_draw_scroll_text *scrollText)
|
||||
{
|
||||
if (gConfigGeneral.upper_case_banners) {
|
||||
format_string_to_upper(dst, scrollText->string_id, &scrollText->string_args_0);
|
||||
} else {
|
||||
format_string(dst, scrollText->string_id, &scrollText->string_args_0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006C42D9
|
||||
* @param stringId (ax)
|
||||
* @param scroll (cx)
|
||||
* @param scrollingMode (bp)
|
||||
* @returns ebx
|
||||
*/
|
||||
int scrolling_text_setup(rct_string_id stringId, uint16 scroll, uint16 scrollingMode)
|
||||
{
|
||||
rct_drawpixelinfo* dpi = RCT2_GLOBAL(0x140E9A8, rct_drawpixelinfo*);
|
||||
|
||||
if (dpi->zoom_level != 0) return 0x626;
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_DRAW_SCROLL_NEXT_ID, uint32)++;
|
||||
|
||||
int scrollIndex = scrolling_text_get_matching_or_oldest(stringId, scroll, scrollingMode);
|
||||
if (scrollIndex >= 0x606) return scrollIndex;
|
||||
|
||||
// Setup scrolling text
|
||||
rct_draw_scroll_text* scrollText = &gDrawScrollTextList[scrollIndex];
|
||||
scrollText->string_id = stringId;
|
||||
scrollText->string_args_0 = RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, uint32);
|
||||
scrollText->string_args_1 = RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 4, uint32);
|
||||
scrollText->position = scroll;
|
||||
scrollText->mode = scrollingMode;
|
||||
scrollText->id = RCT2_GLOBAL(RCT2_ADDRESS_DRAW_SCROLL_NEXT_ID, uint32);
|
||||
|
||||
// Create the string to draw
|
||||
utf8 scrollString[256];
|
||||
scrolling_text_format(scrollString, scrollText);
|
||||
|
||||
sint16* scrollingModePositions = RCT2_ADDRESS(RCT2_ADDRESS_SCROLLING_MODE_POSITIONS, uint16*)[scrollingMode];
|
||||
|
||||
memset(scrollText->bitmap, 0, 320 * 8);
|
||||
if (gUseTrueTypeFont) {
|
||||
scrolling_text_set_bitmap_for_ttf(scrollString, scroll, scrollText->bitmap, scrollingModePositions);
|
||||
} else {
|
||||
scrolling_text_set_bitmap_for_sprite(scrollString, scroll, scrollText->bitmap, scrollingModePositions);
|
||||
}
|
||||
|
||||
return scrollIndex + 0x606;
|
||||
}
|
||||
|
||||
void scrolling_text_set_bitmap_for_sprite(utf8 *text, int scroll, uint8 *bitmap, sint16 *scrollPositionOffsets)
|
||||
{
|
||||
uint8 characterColour = scrolling_text_get_colour(RCT2_GLOBAL(0x013CE959, uint8));
|
||||
|
||||
utf8 *ch = text;
|
||||
while (true) {
|
||||
uint32 codepoint = utf8_get_next(ch, &ch);
|
||||
|
||||
// If at the end of the string loop back to the start
|
||||
if (codepoint == 0) {
|
||||
ch = text;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set any change in colour
|
||||
if (codepoint <= FORMAT_COLOUR_CODE_END && codepoint >= FORMAT_COLOUR_CODE_START){
|
||||
codepoint -= FORMAT_COLOUR_CODE_START;
|
||||
characterColour = RCT2_GLOBAL(0x009FF048, uint8*)[codepoint * 4];
|
||||
continue;
|
||||
}
|
||||
|
||||
// If another type of control character ignore
|
||||
if (codepoint < 32) continue;
|
||||
|
||||
int characterWidth = font_sprite_get_codepoint_width(FONT_SPRITE_BASE_TINY, codepoint);
|
||||
uint8 *characterBitmap = font_sprite_get_codepoint_bitmap(codepoint);
|
||||
for (; characterWidth != 0; characterWidth--, characterBitmap++) {
|
||||
// Skip any none displayed columns
|
||||
if (scroll != 0) {
|
||||
scroll--;
|
||||
continue;
|
||||
}
|
||||
|
||||
sint16 scrollPosition = *scrollPositionOffsets;
|
||||
if (scrollPosition == -1) return;
|
||||
if (scrollPosition > -1) {
|
||||
uint8 *dst = &bitmap[scrollPosition];
|
||||
for (uint8 char_bitmap = *characterBitmap; char_bitmap != 0; char_bitmap >>= 1){
|
||||
if (char_bitmap & 1) *dst = characterColour;
|
||||
|
||||
// Jump to next row
|
||||
dst += 64;
|
||||
}
|
||||
}
|
||||
scrollPositionOffsets++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TTFFontDescriptor *ttf_get_font_from_sprite_base(uint16 spriteBase);
|
||||
SDL_Surface *_ttf_surface_cache_get_or_add(TTF_Font *font, const utf8 *text);
|
||||
|
||||
void scrolling_text_set_bitmap_for_ttf(utf8 *text, int scroll, uint8 *bitmap, sint16 *scrollPositionOffsets)
|
||||
{
|
||||
TTFFontDescriptor *fontDesc = ttf_get_font_from_sprite_base(FONT_SPRITE_BASE_TINY);
|
||||
if (fontDesc->font == NULL) {
|
||||
scrolling_text_set_bitmap_for_sprite(text, scroll, bitmap, scrollPositionOffsets);
|
||||
return;
|
||||
}
|
||||
|
||||
// Currently only supports one colour
|
||||
uint8 colour = 0;
|
||||
|
||||
utf8 *dstCh = text;
|
||||
utf8 *ch = text;
|
||||
int codepoint;
|
||||
while ((codepoint = utf8_get_next(ch, &ch)) != 0) {
|
||||
if (utf8_is_format_code(codepoint)) {
|
||||
if (codepoint >= FORMAT_COLOUR_CODE_START && codepoint <= FORMAT_COLOUR_CODE_END) {
|
||||
colour = (uint8)codepoint;
|
||||
}
|
||||
} else {
|
||||
dstCh = utf8_write_codepoint(dstCh, codepoint);
|
||||
}
|
||||
}
|
||||
*dstCh = 0;
|
||||
|
||||
if (colour == 0) {
|
||||
colour = scrolling_text_get_colour(RCT2_GLOBAL(0x013CE959, uint8));
|
||||
} else {
|
||||
colour = RCT2_GLOBAL(0x009FF048, uint8*)[(colour - FORMAT_COLOUR_CODE_START) * 4];
|
||||
}
|
||||
|
||||
SDL_Surface *surface = _ttf_surface_cache_get_or_add(fontDesc->font, text);
|
||||
if (surface == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (SDL_MUSTLOCK(surface) && SDL_LockSurface(surface) == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
int pitch = surface->pitch;
|
||||
int width = surface->w;
|
||||
int height = surface->h;
|
||||
uint8 *src = surface->pixels;
|
||||
|
||||
// Offset
|
||||
height -= 3;
|
||||
src += 3 * pitch;
|
||||
height = min(height, 8);
|
||||
|
||||
int x = 0;
|
||||
while (true) {
|
||||
// Skip any none displayed columns
|
||||
if (scroll == 0) {
|
||||
sint16 scrollPosition = *scrollPositionOffsets;
|
||||
if (scrollPosition == -1) return;
|
||||
if (scrollPosition > -1) {
|
||||
uint8 *dst = &bitmap[scrollPosition];
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
if (src[y * pitch + x] != 0) *dst = colour;
|
||||
|
||||
// Jump to next row
|
||||
dst += 64;
|
||||
}
|
||||
}
|
||||
scrollPositionOffsets++;
|
||||
} else {
|
||||
scroll--;
|
||||
}
|
||||
|
||||
x++;
|
||||
if (x >= width) x = 0;
|
||||
}
|
||||
|
||||
if (SDL_MUSTLOCK(surface)) SDL_UnlockSurface(surface);
|
||||
}
|
||||
+824
-729
File diff suppressed because it is too large.
Load diff
@@ -499,6 +499,7 @@ static int editor_read_s6(const char *path)
|
||||
news_item_init_queue();
|
||||
window_editor_main_open();
|
||||
editor_finalise_main_view();
|
||||
game_convert_strings_to_utf8();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
+61
@@ -589,6 +589,66 @@ static void load_landscape()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts all the user strings and news item strings to UTF-8.
|
||||
*/
|
||||
void game_convert_strings_to_utf8()
|
||||
{
|
||||
utf8 buffer[512];
|
||||
|
||||
// User strings
|
||||
for (int i = 0; i < MAX_USER_STRINGS; i++) {
|
||||
utf8 *userString = &gUserStrings[i * USER_STRING_MAX_LENGTH];
|
||||
|
||||
if (!str_is_null_or_empty(userString)) {
|
||||
rct2_to_utf8(buffer, userString);
|
||||
memcpy(userString, buffer, 31);
|
||||
userString[31] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// News items
|
||||
for (int i = 0; i < MAX_NEWS_ITEMS; i++) {
|
||||
rct_news_item *newsItem = news_item_get(i);
|
||||
|
||||
if (!str_is_null_or_empty(newsItem->text)) {
|
||||
rct2_to_utf8(buffer, newsItem->text);
|
||||
memcpy(newsItem->text, buffer, 255);
|
||||
newsItem->text[255] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts all the user strings and news item strings to RCT2 encoding.
|
||||
*/
|
||||
void game_convert_strings_to_rct2(rct_s6_data *s6)
|
||||
{
|
||||
char buffer[512];
|
||||
|
||||
// User strings
|
||||
for (int i = 0; i < MAX_USER_STRINGS; i++) {
|
||||
char *userString = &s6->custom_strings[i * USER_STRING_MAX_LENGTH];
|
||||
|
||||
if (!str_is_null_or_empty(userString)) {
|
||||
utf8_to_rct2(buffer, userString);
|
||||
memcpy(userString, buffer, 31);
|
||||
userString[31] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// News items
|
||||
for (int i = 0; i < MAX_NEWS_ITEMS; i++) {
|
||||
rct_news_item *newsItem = &s6->news_items[i];
|
||||
|
||||
if (!str_is_null_or_empty(newsItem->text)) {
|
||||
utf8_to_rct2(buffer, newsItem->text);
|
||||
memcpy(newsItem->text, buffer, 255);
|
||||
newsItem->text[255] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00675E1B
|
||||
@@ -650,6 +710,7 @@ int game_load_sv6(SDL_RWops* rw)
|
||||
map_update_tile_pointers();
|
||||
reset_0x69EBE4();
|
||||
openrct2_reset_object_tween_locations();
|
||||
game_convert_strings_to_utf8();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "common.h"
|
||||
#include "platform/platform.h"
|
||||
#include "scenario.h"
|
||||
|
||||
enum GAME_COMMAND {
|
||||
GAME_COMMAND_SET_RIDE_APPEARANCE,
|
||||
@@ -117,5 +118,7 @@ int save_game();
|
||||
void rct2_exit();
|
||||
void rct2_exit_reason(rct_string_id title, rct_string_id body);
|
||||
void game_autosave();
|
||||
void game_convert_strings_to_utf8();
|
||||
void game_convert_strings_to_rct2(rct_s6_data *s6);
|
||||
|
||||
#endif
|
||||
+38
-3
@@ -25,11 +25,13 @@ void* g_hooktableaddress = 0;
|
||||
int g_hooktableoffset = 0;
|
||||
int g_maxhooks = 1000;
|
||||
|
||||
void hookfunc(int address, int newaddress, int stacksize, int registerargs[], int registersreturned)
|
||||
void hookfunc(int address, int newaddress, int stacksize, int registerargs[], int registersreturned, int eaxDestinationRegister)
|
||||
{
|
||||
int i = 0;
|
||||
char data[100];
|
||||
|
||||
registersreturned |= eaxDestinationRegister;
|
||||
|
||||
int registerssaved = 7;
|
||||
int n = registersreturned;
|
||||
for (; n; registerssaved--) {
|
||||
@@ -146,6 +148,39 @@ void hookfunc(int address, int newaddress, int stacksize, int registerargs[], in
|
||||
|
||||
// returnlocation:
|
||||
|
||||
switch (eaxDestinationRegister) {
|
||||
case EBX:
|
||||
// mov ebx, eax
|
||||
data[i++] = 0x8B;
|
||||
data[i++] = 0xD8;
|
||||
break;
|
||||
case ECX:
|
||||
// mov ecx, eax
|
||||
data[i++] = 0x8B;
|
||||
data[i++] = 0xC8;
|
||||
break;
|
||||
case EDX:
|
||||
// mov ecx, eax
|
||||
data[i++] = 0x8B;
|
||||
data[i++] = 0xD0;
|
||||
break;
|
||||
case ESI:
|
||||
// mov ecx, eax
|
||||
data[i++] = 0x8B;
|
||||
data[i++] = 0xF0;
|
||||
break;
|
||||
case EDI:
|
||||
// mov ecx, eax
|
||||
data[i++] = 0x8B;
|
||||
data[i++] = 0xF8;
|
||||
break;
|
||||
case EBP:
|
||||
// mov ecx, eax
|
||||
data[i++] = 0x8B;
|
||||
data[i++] = 0xE8;
|
||||
break;
|
||||
}
|
||||
|
||||
data[i++] = 0x83; // sub esp, x
|
||||
data[i++] = 0xEC;
|
||||
data[i++] = (signed char)(stacksize * -4) - rargssize;
|
||||
@@ -177,7 +212,7 @@ void hookfunc(int address, int newaddress, int stacksize, int registerargs[], in
|
||||
WriteProcessMemory(GetCurrentProcess(), (LPVOID)address, data, i, 0);
|
||||
}
|
||||
|
||||
void addhook(int address, int newaddress, int stacksize, int registerargs[], int registersreturned)
|
||||
void addhook(int address, int newaddress, int stacksize, int registerargs[], int registersreturned, int eaxDestinationRegister)
|
||||
{
|
||||
if (!g_hooktableaddress) {
|
||||
g_hooktableaddress = VirtualAllocEx(GetCurrentProcess(), NULL, g_maxhooks * 100, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
||||
@@ -192,6 +227,6 @@ void addhook(int address, int newaddress, int stacksize, int registerargs[], int
|
||||
*((int *)&data[i]) = hookaddress - address - i - 4; i += 4;
|
||||
data[i++] = 0xC3; // retn
|
||||
WriteProcessMemory(GetCurrentProcess(), (LPVOID)address, data, i, 0);
|
||||
hookfunc(hookaddress, newaddress, stacksize, registerargs, registersreturned);
|
||||
hookfunc(hookaddress, newaddress, stacksize, registerargs, registersreturned, eaxDestinationRegister);
|
||||
g_hooktableoffset++;
|
||||
}
|
||||
+1
-1
@@ -32,6 +32,6 @@ enum REGISTER_ARGS {
|
||||
END = 0
|
||||
};
|
||||
|
||||
void addhook(int address, int newaddress, int stacksize, int registerargs[], int registersreturned);
|
||||
void addhook(int address, int newaddress, int stacksize, int registerargs[], int registersreturned, int eaxDestinationRegister);
|
||||
|
||||
#endif
|
||||
+1
-1
@@ -959,7 +959,7 @@ void process_mouse_over(int x, int y)
|
||||
int ebx, esi, edi, ebp;
|
||||
|
||||
cursorId = CURSOR_ARROW;
|
||||
RCT2_GLOBAL(0x9A9808, sint16) = -1;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_MAP_TOOLTIP_ARGS, sint16) = -1;
|
||||
window = window_find_from_point(x, y);
|
||||
|
||||
if (window != NULL) {
|
||||
|
||||
+83
-79
@@ -29,17 +29,17 @@ bool gConsoleOpen = false;
|
||||
static bool _consoleInitialised = false;
|
||||
static int _consoleLeft, _consoleTop, _consoleRight, _consoleBottom;
|
||||
static int _lastMainViewportX, _lastMainViewportY;
|
||||
static char _consoleBuffer[CONSOLE_BUFFER_SIZE] = { 0 };
|
||||
static char *_consoleBufferPointer = _consoleBuffer;
|
||||
static char *_consoleViewBufferStart = _consoleBuffer;
|
||||
static char _consoleCurrentLine[CONSOLE_INPUT_SIZE];
|
||||
static char *_consoleCurrentLinePointer = _consoleCurrentLine;
|
||||
static utf8 _consoleBuffer[CONSOLE_BUFFER_SIZE] = { 0 };
|
||||
static utf8 *_consoleBufferPointer = _consoleBuffer;
|
||||
static utf8 *_consoleViewBufferStart = _consoleBuffer;
|
||||
static utf8 _consoleCurrentLine[CONSOLE_INPUT_SIZE];
|
||||
static utf8 *_consoleCurrentLinePointer = _consoleCurrentLine;
|
||||
static int _consoleCaretTicks;
|
||||
static char _consolePrintfBuffer[CONSOLE_BUFFER_2_SIZE];
|
||||
static char _consoleErrorBuffer[CONSOLE_BUFFER_2_SIZE];
|
||||
static utf8 _consolePrintfBuffer[CONSOLE_BUFFER_2_SIZE];
|
||||
static utf8 _consoleErrorBuffer[CONSOLE_BUFFER_2_SIZE];
|
||||
static int _consoleScrollPos = 0;
|
||||
|
||||
static char _consoleHistory[CONSOLE_HISTORY_SIZE][CONSOLE_INPUT_SIZE];
|
||||
static utf8 _consoleHistory[CONSOLE_HISTORY_SIZE][CONSOLE_INPUT_SIZE];
|
||||
static int _consoleHistoryIndex = 0;
|
||||
static int _consoleHistoryCount = 0;
|
||||
|
||||
@@ -47,14 +47,14 @@ static void console_invalidate();
|
||||
static void console_write_prompt();
|
||||
static void console_update_scroll();
|
||||
static void console_clear_input();
|
||||
static void console_history_add(const char *src);
|
||||
static void console_history_add(const utf8 *src);
|
||||
static void console_write_all_commands();
|
||||
static int console_parse_int(const char *src, bool *valid);
|
||||
static double console_parse_double(const char *src, bool *valid);
|
||||
static int console_parse_int(const utf8 *src, bool *valid);
|
||||
static double console_parse_double(const utf8 *src, bool *valid);
|
||||
|
||||
static int cc_variables(const char **argv, int argc);
|
||||
static int cc_windows(const char **argv, int argc);
|
||||
static int cc_help(const char **argv, int argc);
|
||||
static int cc_variables(const utf8 **argv, int argc);
|
||||
static int cc_windows(const utf8 **argv, int argc);
|
||||
static int cc_help(const utf8 **argv, int argc);
|
||||
|
||||
static bool invalidArguments(bool *invalid, bool arguments);
|
||||
|
||||
@@ -121,12 +121,7 @@ void console_update()
|
||||
}
|
||||
|
||||
// Remove unwated characters in console input
|
||||
unsigned char *ch = (unsigned char*)_consoleCurrentLine;
|
||||
while (*ch != 0) {
|
||||
if (*ch < 32 || *ch > 126)
|
||||
*ch = ' ';
|
||||
ch++;
|
||||
}
|
||||
utf8_remove_format_codes(_consoleCurrentLine);
|
||||
}
|
||||
|
||||
// Flash the caret
|
||||
@@ -137,19 +132,21 @@ void console_draw(rct_drawpixelinfo *dpi)
|
||||
{
|
||||
if (!gConsoleOpen)
|
||||
return;
|
||||
|
||||
// Set font
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = (gConfigInterface.console_small_font ? FONT_SPRITE_BASE_SMALL : FONT_SPRITE_BASE_MEDIUM);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_FLAGS, uint16) = 0;
|
||||
int lineHeight = font_get_line_height(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16));
|
||||
|
||||
int lines = 0;
|
||||
int maxLines = ((_consoleBottom - 22 - _consoleTop) / 10) - 1;
|
||||
char *ch = strchr(_consoleBuffer, 0);
|
||||
int maxLines = ((_consoleBottom - 22 - _consoleTop) / lineHeight) - 1;
|
||||
utf8 *ch = strchr(_consoleBuffer, 0);
|
||||
while (ch > _consoleBuffer) {
|
||||
ch--;
|
||||
if (*ch == '\n')
|
||||
lines++;
|
||||
}
|
||||
|
||||
// Set font
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = (gConfigInterface.console_small_font ? 0 : 224);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_FLAGS, uint16) = 0;
|
||||
|
||||
// Background
|
||||
gfx_fill_rect(dpi, _consoleLeft, _consoleTop, _consoleRight, _consoleBottom, 10);
|
||||
|
||||
@@ -157,13 +154,13 @@ void console_draw(rct_drawpixelinfo *dpi)
|
||||
int y = _consoleTop + 4;
|
||||
|
||||
// Draw previous lines
|
||||
char lineBuffer[1 + 256];
|
||||
utf8 lineBuffer[2 + 256], *lineCh;
|
||||
ch = _consoleViewBufferStart;
|
||||
int currentLine = 0;
|
||||
int drawLines = 0;
|
||||
while (*ch != 0) {
|
||||
// Find line break or null terminator
|
||||
char *nextLine = ch;
|
||||
utf8 *nextLine = ch;
|
||||
while (*nextLine != 0 && *nextLine != '\n') {
|
||||
nextLine++;
|
||||
}
|
||||
@@ -173,7 +170,7 @@ void console_draw(rct_drawpixelinfo *dpi)
|
||||
if (*nextLine == '\n') {
|
||||
ch = nextLine + 1;
|
||||
x = _consoleLeft + 4;
|
||||
//y += 10;
|
||||
// y += lineHeight;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
@@ -185,10 +182,11 @@ void console_draw(rct_drawpixelinfo *dpi)
|
||||
break;
|
||||
drawLines++;
|
||||
|
||||
int lineLength = min(sizeof(lineBuffer) - 1, nextLine - ch);
|
||||
strncpy(lineBuffer + 1, ch, lineLength);
|
||||
lineBuffer[0] = FORMAT_GREEN;
|
||||
lineBuffer[1 + lineLength] = 0;
|
||||
int lineLength = min(sizeof(lineBuffer) - (size_t)utf8_get_codepoint_length(FORMAT_GREEN), (size_t)(nextLine - ch));
|
||||
lineCh = lineBuffer;
|
||||
lineCh = utf8_write_codepoint(lineCh, FORMAT_GREEN);
|
||||
strncpy(lineCh, ch, lineLength);
|
||||
lineCh[lineLength] = 0;
|
||||
|
||||
gfx_draw_string(dpi, lineBuffer, 255, x, y);
|
||||
|
||||
@@ -197,16 +195,18 @@ void console_draw(rct_drawpixelinfo *dpi)
|
||||
if (*nextLine == '\n') {
|
||||
ch = nextLine + 1;
|
||||
x = _consoleLeft + 4;
|
||||
y += 10;
|
||||
y += lineHeight;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
x = _consoleLeft + 4;
|
||||
y = _consoleBottom - 15;
|
||||
|
||||
// Draw current line
|
||||
strcpy(lineBuffer + 1, _consoleCurrentLine);
|
||||
lineBuffer[0] = FORMAT_GREEN;
|
||||
lineCh = lineBuffer;
|
||||
lineCh = utf8_write_codepoint(lineCh, FORMAT_GREEN);
|
||||
strcpy(lineCh, _consoleCurrentLine);
|
||||
gfx_draw_string(dpi, lineBuffer, 255, x, y);
|
||||
|
||||
// Draw caret
|
||||
@@ -214,7 +214,7 @@ void console_draw(rct_drawpixelinfo *dpi)
|
||||
memcpy(lineBuffer, _consoleCurrentLine, gTextInputCursorPosition);
|
||||
lineBuffer[gTextInputCursorPosition] = 0;
|
||||
int caretX = x + gfx_get_string_width(lineBuffer);
|
||||
int caretY = y + 10;
|
||||
int caretY = y + lineHeight;
|
||||
|
||||
gfx_fill_rect(dpi, caretX, caretY, caretX + 6, caretY + 1, FORMAT_GREEN);
|
||||
}
|
||||
@@ -273,7 +273,7 @@ static void console_write_prompt()
|
||||
console_write("> ");
|
||||
}
|
||||
|
||||
void console_write(const char *src)
|
||||
void console_write(const utf8 *src)
|
||||
{
|
||||
int charactersRemainingInBuffer = CONSOLE_BUFFER_SIZE - (_consoleBufferPointer - _consoleBuffer) - 1;
|
||||
int charactersToWrite = strlen(src);
|
||||
@@ -287,27 +287,27 @@ void console_write(const char *src)
|
||||
console_update_scroll();
|
||||
}
|
||||
|
||||
void console_writeline(const char *src)
|
||||
void console_writeline(const utf8 *src)
|
||||
{
|
||||
console_write(src);
|
||||
console_write("\n");
|
||||
}
|
||||
|
||||
void console_writeline_error(const char *src)
|
||||
void console_writeline_error(const utf8 *src)
|
||||
{
|
||||
strcpy(_consoleErrorBuffer + 1, src);
|
||||
_consoleErrorBuffer[0] = FORMAT_RED;
|
||||
console_writeline(_consoleErrorBuffer);
|
||||
}
|
||||
|
||||
void console_writeline_warning(const char *src)
|
||||
void console_writeline_warning(const utf8 *src)
|
||||
{
|
||||
strcpy(_consoleErrorBuffer + 1, src);
|
||||
_consoleErrorBuffer[0] = FORMAT_YELLOW;
|
||||
console_writeline(_consoleErrorBuffer);
|
||||
}
|
||||
|
||||
void console_printf(const char *format, ...)
|
||||
void console_printf(const utf8 *format, ...)
|
||||
{
|
||||
va_list list;
|
||||
va_start(list, format);
|
||||
@@ -316,15 +316,15 @@ void console_printf(const char *format, ...)
|
||||
console_writeline(_consolePrintfBuffer);
|
||||
}
|
||||
|
||||
int console_parse_int(const char *src, bool *valid) {
|
||||
char *end;
|
||||
int console_parse_int(const utf8 *src, bool *valid) {
|
||||
utf8 *end;
|
||||
int value;
|
||||
value = strtol(src, &end, 10); *valid = (*end == '\0');
|
||||
return value;
|
||||
}
|
||||
|
||||
double console_parse_double(const char *src, bool *valid) {
|
||||
char *end;
|
||||
double console_parse_double(const utf8 *src, bool *valid) {
|
||||
utf8 *end;
|
||||
double value;
|
||||
value = strtod(src, &end); *valid = (*end == '\0');
|
||||
return value;
|
||||
@@ -351,7 +351,7 @@ void console_scroll(int delta)
|
||||
int speed = 3;
|
||||
int lines = 0;
|
||||
int maxLines = ((_consoleBottom - 22 - _consoleTop) / 10) - 1;
|
||||
char *ch = strchr(_consoleBuffer, 0);
|
||||
utf8 *ch = strchr(_consoleBuffer, 0);
|
||||
while (ch > _consoleBuffer) {
|
||||
ch--;
|
||||
if (*ch == '\n')
|
||||
@@ -390,7 +390,7 @@ static void console_clear_input()
|
||||
gTextInputLength = 0;
|
||||
}
|
||||
|
||||
static void console_history_add(const char *src)
|
||||
static void console_history_add(const utf8 *src)
|
||||
{
|
||||
if (_consoleHistoryCount >= CONSOLE_HISTORY_SIZE) {
|
||||
for (int i = 0; i < _consoleHistoryCount - 1; i++)
|
||||
@@ -401,26 +401,26 @@ static void console_history_add(const char *src)
|
||||
_consoleHistoryIndex = _consoleHistoryCount;
|
||||
}
|
||||
|
||||
static int cc_clear(const char **argv, int argc)
|
||||
static int cc_clear(const utf8 **argv, int argc)
|
||||
{
|
||||
console_clear();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cc_hide(const char **argv, int argc)
|
||||
static int cc_hide(const utf8 **argv, int argc)
|
||||
{
|
||||
console_close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cc_echo(const char **argv, int argc)
|
||||
static int cc_echo(const utf8 **argv, int argc)
|
||||
{
|
||||
if (argc > 0)
|
||||
console_writeline(argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cc_get(const char **argv, int argc)
|
||||
static int cc_get(const utf8 **argv, int argc)
|
||||
{
|
||||
if (argc > 0) {
|
||||
if (strcmp(argv[0], "park_rating") == 0) {
|
||||
@@ -496,7 +496,7 @@ static int cc_get(const char **argv, int argc)
|
||||
console_printf("construction_rights_cost %d.%d0", RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCTION_RIGHTS_COST, money32) / 10, RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCTION_RIGHTS_COST, money32) % 10);
|
||||
}
|
||||
else if (strcmp(argv[0], "climate") == 0) {
|
||||
const char* climate_names[] = { "cool_and_wet", "warm", "hot_and_dry", "cold" };
|
||||
const utf8* climate_names[] = { "cool_and_wet", "warm", "hot_and_dry", "cold" };
|
||||
console_printf("climate %s (%d)", climate_names[RCT2_GLOBAL(RCT2_ADDRESS_CLIMATE, sint8)], RCT2_GLOBAL(RCT2_ADDRESS_CLIMATE, sint8));
|
||||
}
|
||||
else if (strcmp(argv[0], "game_speed") == 0) {
|
||||
@@ -533,7 +533,7 @@ static int cc_get(const char **argv, int argc)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static int cc_set(const char **argv, int argc)
|
||||
static int cc_set(const utf8 **argv, int argc)
|
||||
{
|
||||
int i;
|
||||
if (argc > 1) {
|
||||
@@ -639,7 +639,7 @@ static int cc_set(const char **argv, int argc)
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CLIMATE, sint8) = clamp(int_val[0], 0, 3);
|
||||
}
|
||||
else {
|
||||
char* climate_names[] = { "cool_and_wet", "warm", "hot_and_dry", "cold" };
|
||||
utf8* climate_names[] = { "cool_and_wet", "warm", "hot_and_dry", "cold" };
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (strcmp(argv[1], climate_names[i]) == 0) {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CLIMATE, sint8) = i;
|
||||
@@ -697,7 +697,7 @@ static int cc_set(const char **argv, int argc)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static int cc_twitch(const char **argv, int argc)
|
||||
static int cc_twitch(const utf8 **argv, int argc)
|
||||
{
|
||||
#ifdef DISABLE_TWITCH
|
||||
console_writeline_error("OpenRCT2 build not compiled with Twitch integeration.");
|
||||
@@ -706,6 +706,7 @@ static int cc_twitch(const char **argv, int argc)
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void editor_load_selected_objects_console()
|
||||
{
|
||||
uint8 *selection_flags = RCT2_GLOBAL(RCT2_ADDRESS_EDITOR_OBJECT_FLAGS_LIST, uint8*);
|
||||
@@ -729,13 +730,13 @@ static void editor_load_selected_objects_console()
|
||||
}
|
||||
}
|
||||
|
||||
static int cc_load_object(const char **argv, int argc) {
|
||||
static int cc_load_object(const utf8 **argv, int argc) {
|
||||
if (argc > 0) {
|
||||
char path[260];
|
||||
utf8 path[260];
|
||||
|
||||
subsitute_path(path, RCT2_ADDRESS(RCT2_ADDRESS_OBJECT_DATA_PATH, char), argv[0]);
|
||||
// Require pointer to start of filename
|
||||
char* last_char = path + strlen(path);
|
||||
utf8* last_char = path + strlen(path);
|
||||
strcat(path, ".DAT\0");
|
||||
|
||||
rct_object_entry entry;
|
||||
@@ -815,8 +816,8 @@ static int cc_load_object(const char **argv, int argc) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
static int cc_object_count(const char **argv, int argc) {
|
||||
const char* object_type_names[] = { "Rides", "Small scenery", "Large scenery", "Walls", "Banners", "Paths", "Path Additions", "Scenery groups", "Park entrances", "Water" };
|
||||
static int cc_object_count(const utf8 **argv, int argc) {
|
||||
const utf8* object_type_names[] = { "Rides", "Small scenery", "Large scenery", "Walls", "Banners", "Paths", "Path Additions", "Scenery groups", "Park entrances", "Water" };
|
||||
for (int i = 0; i < 10; i++) {
|
||||
|
||||
int entryGroupIndex = 0;
|
||||
@@ -830,7 +831,7 @@ static int cc_object_count(const char **argv, int argc) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
static int cc_open(const char **argv, int argc) {
|
||||
static int cc_open(const utf8 **argv, int argc) {
|
||||
if (argc > 0) {
|
||||
bool title = (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TITLE_DEMO) != 0;
|
||||
bool invalidTitle = false;
|
||||
@@ -858,15 +859,15 @@ static int cc_open(const char **argv, int argc) {
|
||||
}
|
||||
|
||||
|
||||
typedef int (*console_command_func)(const char **argv, int argc);
|
||||
typedef int (*console_command_func)(const utf8 **argv, int argc);
|
||||
typedef struct {
|
||||
char *command;
|
||||
utf8 *command;
|
||||
console_command_func func;
|
||||
char *help;
|
||||
char *usage;
|
||||
utf8 *help;
|
||||
utf8 *usage;
|
||||
} console_command;
|
||||
|
||||
char* console_variable_table[] = {
|
||||
utf8* console_variable_table[] = {
|
||||
"park_rating",
|
||||
"money",
|
||||
"current_loan",
|
||||
@@ -895,7 +896,7 @@ char* console_variable_table[] = {
|
||||
"no_test_crashes",
|
||||
"location"
|
||||
};
|
||||
char* console_window_table[] = {
|
||||
utf8* console_window_table[] = {
|
||||
"object_selection",
|
||||
"inventions_list",
|
||||
"scenario_options",
|
||||
@@ -922,19 +923,19 @@ console_command console_command_table[] = {
|
||||
{ "twitch", cc_twitch, "Twitch API" }
|
||||
};
|
||||
|
||||
static int cc_windows(const char **argv, int argc) {
|
||||
static int cc_windows(const utf8 **argv, int argc) {
|
||||
for (int i = 0; i < countof(console_window_table); i++)
|
||||
console_writeline(console_window_table[i]);
|
||||
return 0;
|
||||
}
|
||||
static int cc_variables(const char **argv, int argc)
|
||||
static int cc_variables(const utf8 **argv, int argc)
|
||||
{
|
||||
for (int i = 0; i < countof(console_variable_table); i++)
|
||||
console_writeline(console_variable_table[i]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cc_help(const char **argv, int argc)
|
||||
static int cc_help(const utf8 **argv, int argc)
|
||||
{
|
||||
if (argc > 0) {
|
||||
for (int i = 0; i < countof(console_command_table); i++) {
|
||||
@@ -956,20 +957,20 @@ static void console_write_all_commands()
|
||||
console_writeline(console_command_table[i].command);
|
||||
}
|
||||
|
||||
void console_execute(const char *src)
|
||||
void console_execute(const utf8 *src)
|
||||
{
|
||||
console_writeline(src);
|
||||
|
||||
console_execute_silent(src);
|
||||
}
|
||||
|
||||
void console_execute_silent(const char *src)
|
||||
void console_execute_silent(const utf8 *src)
|
||||
{
|
||||
int argc = 0;
|
||||
int argvCapacity = 8;
|
||||
char **argv = malloc(argvCapacity * sizeof(char*));
|
||||
const char *start = src;
|
||||
const char *end;
|
||||
utf8 **argv = malloc(argvCapacity * sizeof(utf8*));
|
||||
const utf8 *start = src;
|
||||
const utf8 *end;
|
||||
bool inQuotes = false;
|
||||
do {
|
||||
while (*start == ' ')
|
||||
@@ -994,13 +995,13 @@ void console_execute_silent(const char *src)
|
||||
int length = end - start;
|
||||
|
||||
if (length > 0) {
|
||||
char *arg = malloc(length + 1);
|
||||
utf8 *arg = malloc(length + 1);
|
||||
memcpy(arg, start, length);
|
||||
arg[length] = 0;
|
||||
|
||||
if (argc >= argvCapacity) {
|
||||
argvCapacity *= 2;
|
||||
argv = realloc(argv, argvCapacity * sizeof(char*));
|
||||
argv = realloc(argv, argvCapacity * sizeof(utf8*));
|
||||
}
|
||||
argv[argc] = arg;
|
||||
argc++;
|
||||
@@ -1030,7 +1031,10 @@ void console_execute_silent(const char *src)
|
||||
free(argv);
|
||||
|
||||
if (!validCommand) {
|
||||
char output[] = { FORMAT_RED, "Unknown command. Type help to list available commands." };
|
||||
utf8 output[128];
|
||||
utf8 *dst = output;
|
||||
dst = utf8_write_codepoint(dst, FORMAT_RED);
|
||||
strcpy(dst, "Unknown command. Type help to list available commands.");
|
||||
console_writeline(output);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,13 +14,13 @@ void console_update();
|
||||
void console_draw(rct_drawpixelinfo *dpi);
|
||||
|
||||
void console_input(int c);
|
||||
void console_write(const char *src);
|
||||
void console_writeline(const char *src);
|
||||
void console_writeline_error(const char *src);
|
||||
void console_writeline_warning(const char *src);
|
||||
void console_printf(const char *format, ...);
|
||||
void console_execute(const char *src);
|
||||
void console_execute_silent(const char *src);
|
||||
void console_write(const utf8 *src);
|
||||
void console_writeline(const utf8 *src);
|
||||
void console_writeline_error(const utf8 *src);
|
||||
void console_writeline_warning(const utf8 *src);
|
||||
void console_printf(const utf8 *format, ...);
|
||||
void console_execute(const utf8 *src);
|
||||
void console_execute_silent(const utf8 *src);
|
||||
void console_clear();
|
||||
void console_clear_line();
|
||||
void console_refresh_caret();
|
||||
|
||||
+43
-125
@@ -990,130 +990,6 @@ void sprite_paint_setup(uint16 eax, uint16 ecx){
|
||||
}
|
||||
}
|
||||
|
||||
/* size: 0xA12 */
|
||||
typedef struct{
|
||||
rct_string_id string_id; // 0x00
|
||||
uint32 string_args_0; // 0x02
|
||||
uint32 string_args_1; // 0x06
|
||||
uint16 position; // 0x0A
|
||||
uint16 mode; // 0x0C
|
||||
uint32 id; // 0x0E
|
||||
uint8 bitmap[64 * 8 * 5];// 0x12
|
||||
}rct_draw_scroll_text;
|
||||
|
||||
/*rct2: 0x006C42D9*/
|
||||
int scrolling_text_setup(rct_string_id string_id, uint16 scroll, uint16 scrolling_mode)
|
||||
{
|
||||
rct_drawpixelinfo* dpi = RCT2_GLOBAL(0x140E9A8, rct_drawpixelinfo*);
|
||||
|
||||
if (dpi->zoom_level != 0) return 0x626;
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_DRAW_SCROLL_NEXT_ID, uint32)++;
|
||||
|
||||
uint32 oldest_id = 0xFFFFFFFF;
|
||||
uint8 scroll_index = 0xFF;
|
||||
rct_draw_scroll_text* oldest_scroll = NULL;
|
||||
|
||||
// Find the oldest scroll for use as the newest
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
rct_draw_scroll_text* scroll_text = &RCT2_ADDRESS(RCT2_ADDRESS_DRAW_SCROLL_LIST, rct_draw_scroll_text)[i];
|
||||
if (oldest_id >= scroll_text->id){
|
||||
oldest_id = scroll_text->id;
|
||||
scroll_index = i;
|
||||
oldest_scroll = scroll_text;
|
||||
}
|
||||
|
||||
// If exact match return the matching index
|
||||
if (scroll_text->string_id == string_id &&
|
||||
scroll_text->string_args_0 == RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint32) &&
|
||||
scroll_text->string_args_1 == RCT2_GLOBAL(0x13CE956, uint32) &&
|
||||
scroll_text->position == scroll &&
|
||||
scroll_text->mode == scrolling_mode){
|
||||
|
||||
scroll_text->id = RCT2_GLOBAL(RCT2_ADDRESS_DRAW_SCROLL_NEXT_ID, uint32);
|
||||
return i + 0x606;
|
||||
}
|
||||
}
|
||||
|
||||
// Setup scrolling text
|
||||
|
||||
rct_draw_scroll_text* scroll_text = oldest_scroll;
|
||||
scroll_text->string_id = string_id;
|
||||
scroll_text->string_args_0 = RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint32);
|
||||
scroll_text->string_args_1 = RCT2_GLOBAL(0x13CE956, uint32);
|
||||
scroll_text->position = scroll;
|
||||
scroll_text->mode = scrolling_mode;
|
||||
scroll_text->id = RCT2_GLOBAL(RCT2_ADDRESS_DRAW_SCROLL_NEXT_ID, uint32_t);
|
||||
|
||||
uint8* scroll_pixel_pointer = scroll_text->bitmap;
|
||||
memset(scroll_pixel_pointer, 0, 320 * 8);
|
||||
|
||||
// Convert string id back into a string for processing
|
||||
uint8 scroll_string[MAX_PATH];
|
||||
if(gConfigGeneral.upper_case_banners)
|
||||
format_string_to_upper(scroll_string, string_id, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS);
|
||||
else
|
||||
format_string(scroll_string, string_id, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS);
|
||||
|
||||
// Setup character colour from ???
|
||||
uint8 character = RCT2_GLOBAL(0x13CE959, uint8);
|
||||
int edi = character & 0x7F;
|
||||
int offs = 0;
|
||||
if (character >= 0x80) offs = 2;
|
||||
uint8 character_colour = RCT2_ADDRESS(0x0141FC47, uint8)[offs + edi * 8];
|
||||
|
||||
sint16* scrolling_mode_positions = RCT2_ADDRESS(RCT2_ADDRESS_SCROLLING_MODE_POSITIONS, uint16_t*)[scrolling_mode];
|
||||
uint8* format_result = scroll_string;
|
||||
while (true)
|
||||
{
|
||||
character = *format_result++;
|
||||
|
||||
// If at the end of the string loop back to the start
|
||||
if (character == 0){
|
||||
format_result = scroll_string;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set any change in colour
|
||||
if (character <= FORMAT_COLOUR_CODE_END && character >= FORMAT_COLOUR_CODE_START){
|
||||
character -= FORMAT_COLOUR_CODE_START;
|
||||
character_colour = RCT2_GLOBAL(0x9FF048, uint8*)[character * 4];
|
||||
continue;
|
||||
}
|
||||
|
||||
// If another type of control character ignore
|
||||
if (character < 0x20) continue;
|
||||
|
||||
// Convert to an indexable character
|
||||
character -= 0x20;
|
||||
|
||||
uint8 character_width = RCT2_ADDRESS(RCT2_ADDRESS_FONT_CHAR_WIDTH + 0x1C0, uint8)[character];
|
||||
uint8* character_bitmap = &(RCT2_ADDRESS(RCT2_ADDRESS_CHARACTER_BITMAP, uint8)[character * 8]);
|
||||
for (; character_width != 0;character_width--,character_bitmap++)
|
||||
{
|
||||
// Skip any none displayed columns
|
||||
if (scroll != 0){
|
||||
scroll--;
|
||||
continue;
|
||||
}
|
||||
|
||||
sint16 scroll_position = *scrolling_mode_positions;
|
||||
if (scroll_position == -1) return scroll_index + 0x606;
|
||||
if (scroll_position > -1)
|
||||
{
|
||||
uint8* dst = &scroll_pixel_pointer[scroll_position];
|
||||
for (uint8 char_bitmap = *character_bitmap; char_bitmap != 0; char_bitmap >>= 1){
|
||||
if (char_bitmap & 1) *dst = character_colour;
|
||||
// Jump to next row
|
||||
dst += 64;
|
||||
}
|
||||
}
|
||||
scrolling_mode_positions++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* rct2: 0x006629BC
|
||||
* returns al
|
||||
* ebp : image_id
|
||||
@@ -2114,6 +1990,48 @@ void sub_688217()
|
||||
sub_688217_helper(eax & 0xFFFF, 0);
|
||||
}
|
||||
|
||||
typedef struct paint_string_struct paint_string_struct;
|
||||
struct paint_string_struct {
|
||||
rct_string_id string_id; // 0x00
|
||||
paint_string_struct *next; // 0x02
|
||||
uint16 x; // 0x06
|
||||
uint16 y; // 0x08
|
||||
uint8 args[16]; // 0x0A
|
||||
uint8 *y_offsets; // 0x1A
|
||||
};
|
||||
|
||||
static void draw_pixel_info_crop_by_zoom(rct_drawpixelinfo *dpi)
|
||||
{
|
||||
int zoom = dpi->zoom_level;
|
||||
dpi->zoom_level = 0;
|
||||
dpi->x >>= zoom;
|
||||
dpi->y >>= zoom;
|
||||
dpi->width >>= zoom;
|
||||
dpi->height >>= zoom;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2:0x006860C3
|
||||
*/
|
||||
static void viewport_draw_money_effects()
|
||||
{
|
||||
utf8 buffer[256];
|
||||
|
||||
paint_string_struct *ps = RCT2_GLOBAL(0x00F1AD20, paint_string_struct*);
|
||||
if (ps == NULL)
|
||||
return;
|
||||
|
||||
rct_drawpixelinfo dpi = *(RCT2_GLOBAL(0x0140E9A8, rct_drawpixelinfo*));
|
||||
draw_pixel_info_crop_by_zoom(&dpi);
|
||||
|
||||
do {
|
||||
format_string(buffer, ps->string_id, &ps->args);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = FONT_SPRITE_BASE_MEDIUM;
|
||||
gfx_draw_string_with_y_offsets(&dpi, buffer, 0, ps->x, ps->y, ps->y_offsets);
|
||||
} while ((ps = ps->next) != NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2:0x00685CBF
|
||||
@@ -2211,7 +2129,7 @@ void viewport_paint(rct_viewport* viewport, rct_drawpixelinfo* dpi, int left, in
|
||||
if ((weather_colour != -1) && (!(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_VIEWPORT_FLAGS, uint16) & 0x4000)) && (!(RCT2_GLOBAL(0x9DEA6F, uint8) & 1))){
|
||||
gfx_fill_rect(dpi2, dpi2->x, dpi2->y, dpi2->width + dpi2->x - 1, dpi2->height + dpi2->y - 1, weather_colour);
|
||||
}
|
||||
RCT2_CALLPROC_EBPSAFE(0x6860C3); //string related
|
||||
viewport_draw_money_effects();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -754,7 +754,7 @@ static void widget_checkbox_draw(rct_drawpixelinfo *dpi, rct_window *w, int widg
|
||||
// fill it when checkbox is pressed
|
||||
if (widget_is_pressed(w, widgetIndex)) {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224;
|
||||
gfx_draw_string(dpi, (char*)0x009DED72, colour & 0x7F, l, yMid - 5);
|
||||
gfx_draw_string(dpi, (char*)CheckBoxMarkString, colour & 0x7F, l, yMid - 5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -861,7 +861,7 @@ static void widget_hscrollbar_draw(rct_drawpixelinfo *dpi, rct_scroll *scroll, i
|
||||
|
||||
// Left button
|
||||
gfx_fill_rect_inset(dpi, l, t, l + 9, b, colour, (scroll->flags & HSCROLLBAR_LEFT_PRESSED ? 0x20 : 0));
|
||||
gfx_draw_string(dpi, (char*)0x009DED6C, 0, l + 1, t);
|
||||
gfx_draw_string(dpi, (char*)BlackLeftArrowString, 0, l + 1, t);
|
||||
|
||||
// Thumb
|
||||
gfx_fill_rect_inset(dpi,
|
||||
@@ -871,7 +871,7 @@ static void widget_hscrollbar_draw(rct_drawpixelinfo *dpi, rct_scroll *scroll, i
|
||||
|
||||
// Right button
|
||||
gfx_fill_rect_inset(dpi, r - 9, t, r, b, colour, (scroll->flags & HSCROLLBAR_RIGHT_PRESSED ? 0x20 : 0));
|
||||
gfx_draw_string(dpi, (char*)0x009DED6F, 0, r - 6, t);
|
||||
gfx_draw_string(dpi, (char*)BlackRightArrowString, 0, r - 6, t);
|
||||
}
|
||||
|
||||
static void widget_vscrollbar_draw(rct_drawpixelinfo *dpi, rct_scroll *scroll, int l, int t, int r, int b, int colour)
|
||||
@@ -887,7 +887,7 @@ static void widget_vscrollbar_draw(rct_drawpixelinfo *dpi, rct_scroll *scroll, i
|
||||
|
||||
// Up button
|
||||
gfx_fill_rect_inset(dpi, l, t, r, t + 9, colour, (scroll->flags & VSCROLLBAR_UP_PRESSED ? 0x20 : 0));
|
||||
gfx_draw_string(dpi, (char*)0x009DED66, 0, l + 1, t - 1);
|
||||
gfx_draw_string(dpi, (char*)BlackUpArrowString, 0, l + 1, t - 1);
|
||||
|
||||
// Thumb
|
||||
gfx_fill_rect_inset(dpi,
|
||||
@@ -897,7 +897,7 @@ static void widget_vscrollbar_draw(rct_drawpixelinfo *dpi, rct_scroll *scroll, i
|
||||
|
||||
// Down button
|
||||
gfx_fill_rect_inset(dpi, l, b - 9, r, b, colour, (scroll->flags & VSCROLLBAR_DOWN_PRESSED ? 0x20 : 0));
|
||||
gfx_draw_string(dpi, (char*)0x009DED69, 0, l + 1, b - 9);
|
||||
gfx_draw_string(dpi, (char*)BlackDownArrowString, 0, l + 1, b - 9);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1192,7 +1192,7 @@ static void widget_text_box_draw(rct_drawpixelinfo *dpi, rct_window *w, int widg
|
||||
gfx_draw_string(dpi, wrapped_string, w->colours[1], l + 2, t);
|
||||
|
||||
|
||||
int string_length = get_string_length(wrapped_string);
|
||||
int string_length = get_string_size(wrapped_string) - 1;
|
||||
|
||||
// Make a copy of the string for measuring the width.
|
||||
char temp_string[512] = { 0 };
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
+10
-10
@@ -21,14 +21,14 @@
|
||||
#include "currency.h"
|
||||
|
||||
const rct_currency_spec g_currency_specs[CURRENCY_END] = {
|
||||
{ 10 , "\xA3" , CURRENCY_PREFIX }, // British Pound
|
||||
{ 10 , "\x24" , CURRENCY_PREFIX }, // US Dollar
|
||||
{ 10 , "F" , CURRENCY_SUFFIX }, // French Franc
|
||||
{ 10 , "DM" , CURRENCY_PREFIX }, // Deutsche Mark
|
||||
{ 1000 , "\xA5" , CURRENCY_PREFIX }, // Japanese Yen
|
||||
{ 10 , "Pts" , CURRENCY_SUFFIX }, // Spanish Peseta
|
||||
{ 1000 , "L" , CURRENCY_PREFIX }, // Italian Lira
|
||||
{ 10 , "fl. " , CURRENCY_PREFIX }, // Dutch Guilder
|
||||
{ 10 , "kr." , CURRENCY_SUFFIX }, // Swedish Krona
|
||||
{ 10 , "\xb5" , CURRENCY_PREFIX }, // Euro
|
||||
{ 10 , "\xC2\xA3" , CURRENCY_PREFIX }, // British Pound
|
||||
{ 10 , "$" , CURRENCY_PREFIX }, // US Dollar
|
||||
{ 10 , "F" , CURRENCY_SUFFIX }, // French Franc
|
||||
{ 10 , "DM" , CURRENCY_PREFIX }, // Deutsche Mark
|
||||
{ 1000 , "\xC2\xA5" , CURRENCY_PREFIX }, // Japanese Yen
|
||||
{ 10 , "Pts" , CURRENCY_SUFFIX }, // Spanish Peseta
|
||||
{ 1000 , "L" , CURRENCY_PREFIX }, // Italian Lira
|
||||
{ 10 , "fl. " , CURRENCY_PREFIX }, // Dutch Guilder
|
||||
{ 10 , "kr." , CURRENCY_SUFFIX }, // Swedish Krona
|
||||
{ 10 , "\xE2\x82\xAC" , CURRENCY_PREFIX }, // Euro
|
||||
};
|
||||
@@ -21,6 +21,8 @@
|
||||
#ifndef CURRENCY_H
|
||||
#define CURRENCY_H
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
// List of currencies
|
||||
typedef enum {
|
||||
CURRENCY_POUNDS, // British Pound
|
||||
@@ -46,7 +48,7 @@ typedef enum {
|
||||
typedef struct {
|
||||
// Rate is relative to 0.1 GBP
|
||||
int rate;
|
||||
char symbol[8];
|
||||
utf8 symbol[8];
|
||||
int affix;
|
||||
} rct_currency_spec;
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
#ifndef _FORMAT_CODES_H_
|
||||
#define _FORMAT_CODES_H_
|
||||
|
||||
char format_get_code(const char *token);
|
||||
const char *format_get_token(char code);
|
||||
uint32 format_get_code(const char *token);
|
||||
const char *format_get_token(uint32 code);
|
||||
|
||||
enum {
|
||||
// Font format codes
|
||||
@@ -56,9 +56,6 @@ enum {
|
||||
// The next 4 bytes specify the sprite
|
||||
FORMAT_INLINE_SPRITE = 23,
|
||||
|
||||
// Non ascii-characters
|
||||
FORMAT_ENDQUOTES = 34,
|
||||
|
||||
// Argument format codes
|
||||
FORMAT_ARGUMENT_CODE_START = 123,
|
||||
FORMAT_COMMA32 = 123,
|
||||
@@ -80,6 +77,7 @@ enum {
|
||||
FORMAT_REALTIME,
|
||||
FORMAT_LENGTH,
|
||||
FORMAT_SPRITE,
|
||||
FORMAT_ARGUMENT_CODE_END = FORMAT_SPRITE,
|
||||
|
||||
// Colour format codes
|
||||
FORMAT_COLOUR_CODE_START = 142,
|
||||
@@ -101,27 +99,41 @@ enum {
|
||||
|
||||
// Extra non-ascii characters
|
||||
FORMAT_AMINUSCULE = 159,
|
||||
FORMAT_UP,
|
||||
FORMAT_CENT = 162,
|
||||
FORMAT_POUND = 163,
|
||||
FORMAT_YEN = 165,
|
||||
FORMAT_COPYRIGHT = 169,
|
||||
FORMAT_DOWN,
|
||||
FORMAT_LEFTGUILLEMET,
|
||||
FORMAT_TICK,
|
||||
FORMAT_CROSS,
|
||||
FORMAT_RIGHT = 175,
|
||||
FORMAT_DEGREE,
|
||||
FORMAT_LEFTGUILLEMET = 171,
|
||||
FORMAT_DEGREE = 176,
|
||||
FORMAT_SQUARED = 178,
|
||||
FORMAT_OPENQUOTES = 180,
|
||||
FORMAT_EURO = 181,
|
||||
FORMAT_APPROX = 184,
|
||||
FORMAT_POWERNEGATIVEONE,
|
||||
FORMAT_BULLET,
|
||||
FORMAT_RIGHTGUILLEMET,
|
||||
FORMAT_SMALLUP,
|
||||
FORMAT_SMALLDOWN,
|
||||
FORMAT_LEFT,
|
||||
FORMAT_INVERTEDQUESTION
|
||||
FORMAT_RIGHTGUILLEMET = 187,
|
||||
FORMAT_INVERTEDQUESTION = 191,
|
||||
|
||||
FORMAT_OPENQUOTES = 8220,
|
||||
FORMAT_ENDQUOTES = 8221,
|
||||
|
||||
FORMAT_BULLET = 8226,
|
||||
FORMAT_POWERNEGATIVEONE = 8315,
|
||||
FORMAT_EURO = 8364,
|
||||
|
||||
FORMAT_APPROX = 8776,
|
||||
|
||||
FORMAT_UP = 9650,
|
||||
FORMAT_RIGHT = 9654,
|
||||
FORMAT_DOWN = 9660,
|
||||
FORMAT_LEFT = 9664,
|
||||
|
||||
FORMAT_SMALLUP = 9652,
|
||||
FORMAT_SMALLDOWN = 9662,
|
||||
|
||||
FORMAT_TICK = 10003,
|
||||
FORMAT_CROSS = 10005,
|
||||
|
||||
// Format codes that need suitable unicode allocations
|
||||
FORMAT_SYMBOL_i = 20000,
|
||||
FORMAT_SYMBOL_RAILWAY = 20001,
|
||||
FORMAT_SYMBOL_ROAD = 20002,
|
||||
FORMAT_SYMBOL_FLAG = 20003,
|
||||
};
|
||||
|
||||
#endif
|
||||
+238
-84
@@ -19,10 +19,11 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include "../addresses.h"
|
||||
#include "../drawing/drawing.h"
|
||||
#include "../object.h"
|
||||
#include "../openrct2.h"
|
||||
#include "../util/util.h"
|
||||
#include "localisation.h"
|
||||
#include "../openrct2.h"
|
||||
|
||||
typedef struct {
|
||||
int id;
|
||||
@@ -32,64 +33,76 @@ typedef struct {
|
||||
char *string_data;
|
||||
} language_data;
|
||||
|
||||
const char *language_names[LANGUAGE_COUNT] = {
|
||||
"", // LANGUAGE_UNDEFINED
|
||||
"English (UK)", // LANGUAGE_ENGLISH_UK
|
||||
"English (US)", // LANGUAGE_ENGLISH_US
|
||||
"Deutsch", // LANGUAGE_GERMAN
|
||||
"Nederlands", // LANGUAGE_DUTCH
|
||||
"Fran\u00E7ais", // LANGUAGE_FRENCH
|
||||
"Magyar", // LANGUAGE_HUNGARIAN
|
||||
"Polski", // LANGUAGE_POLISH
|
||||
"Espa\u00F1ol", // LANGUAGE_SPANISH
|
||||
"Svenska", // LANGUAGE_SWEDISH
|
||||
"Italiano", // LANGUAGE_ITALIAN
|
||||
"Portug\u00CAs (BR)"// LANGUAGE_PORTUGUESE_BR
|
||||
enum {
|
||||
RCT2_LANGUAGE_ID_ENGLISH_UK,
|
||||
RCT2_LANGUAGE_ID_ENGLISH_US,
|
||||
RCT2_LANGUAGE_ID_FRENCH,
|
||||
RCT2_LANGUAGE_ID_GERMAN,
|
||||
RCT2_LANGUAGE_ID_SPANISH,
|
||||
RCT2_LANGUAGE_ID_ITALIAN,
|
||||
RCT2_LANGUAGE_ID_DUTCH,
|
||||
RCT2_LANGUAGE_ID_SWEDISH,
|
||||
RCT2_LANGUAGE_ID_8,
|
||||
RCT2_LANGUAGE_ID_KOREAN,
|
||||
RCT2_LANGUAGE_ID_CHINESE_SIMPLIFIED,
|
||||
RCT2_LANGUAGE_ID_CHINESE_TRADITIONAL,
|
||||
RCT2_LANGUAGE_ID_12,
|
||||
RCT2_LANGUAGE_ID_PORTUGESE,
|
||||
RCT2_LANGUAGE_ID_END = 255
|
||||
};
|
||||
|
||||
const char *language_filenames[LANGUAGE_COUNT] = {
|
||||
"", // LANGUAGE_UNDEFINED
|
||||
"english_uk", // LANGUAGE_ENGLISH_UK
|
||||
"english_us", // LANGUAGE_ENGLISH_US
|
||||
"german", // LANGUAGE_GERMAN
|
||||
"dutch", // LANGUAGE_DUTCH
|
||||
"french", // LANGUAGE_FRENCH
|
||||
"hungarian", // LANGUAGE_HUNGARIAN
|
||||
"polish", // LANGUAGE_POLISH
|
||||
"spanish_sp", // LANGUAGE_SPANISH
|
||||
"swedish", // LANGUAGE_SWEDISH
|
||||
"italian", // LANGUAGE_ITALIAN
|
||||
"portuguese_br" // LANGUAGE_PORTUGUESE_BR
|
||||
static TTFFontSetDescriptor TTFFontMingliu = {{
|
||||
{ "msjh.ttc", 9, -1, -3, 6, NULL },
|
||||
{ "mingliu.ttc", 11, 1, 1, 12, NULL },
|
||||
{ "mingliu.ttc", 12, 1, 0, 12, NULL },
|
||||
{ "mingliu.ttc", 13, 1, 0, 20, NULL },
|
||||
}};
|
||||
|
||||
const language_descriptor LanguagesDescriptors[LANGUAGE_COUNT] = {
|
||||
{ "", "", "", "", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_ENGLISH_UK }, // LANGUAGE_UNDEFINED
|
||||
{ "en-GB", "English (UK)", "English (UK)", "english_uk", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_ENGLISH_UK }, // LANGUAGE_ENGLISH_UK
|
||||
{ "en-US", "English (US)", "English (US)", "english_us", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_ENGLISH_US }, // LANGUAGE_ENGLISH_US
|
||||
{ "de-DE", "German", "Deutsch", "german", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_GERMAN }, // LANGUAGE_GERMAN
|
||||
{ "nl-NL", "Dutch", "Nederlands", "dutch", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_DUTCH }, // LANGUAGE_DUTCH
|
||||
{ "fr-FR", "French", "Fran\xC3\xA7" "ais", "french", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_FRENCH }, // LANGUAGE_FRENCH
|
||||
{ "hu-HU", "Hungarian", "Magyar", "hungarian", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_ENGLISH_UK }, // LANGUAGE_HUNGARIAN
|
||||
{ "pl-PL", "Polish", "Polski", "polish", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_ENGLISH_UK }, // LANGUAGE_POLISH
|
||||
{ "es-ES", "Spanish", "Espa\xC3\xB1ol", "spanish_sp", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_SPANISH }, // LANGUAGE_SPANISH
|
||||
{ "sv-SE", "Swedish", "Svenska", "swedish", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_SWEDISH }, // LANGUAGE_SWEDISH
|
||||
{ "it-IT", "Italian", "Italiano", "italian", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_ITALIAN }, // LANGUAGE_ITALIAN
|
||||
{ "pt-BR", "Portuguese (BR)", "Portug\xC3\xAAs (BR)", "portuguese_br", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_PORTUGESE }, // LANGUAGE_PORTUGUESE_BR
|
||||
{ "zh-Hant", "Chinese (Traditional)", "Chinese (Traditional)", "chinese_traditional", &TTFFontMingliu, RCT2_LANGUAGE_ID_CHINESE_TRADITIONAL }, // LANGUAGE_CHINESE_TRADITIONAL
|
||||
// { "kr-KR", "Korean", "Korean", "english_uk", "malgun.ttf", RCT2_LANGUAGE_ID_KOREAN }, // LANGUAGE_KOREAN
|
||||
};
|
||||
|
||||
int gCurrentLanguage = LANGUAGE_UNDEFINED;
|
||||
bool gUseTrueTypeFont = false;
|
||||
|
||||
language_data _languageFallback = { 0 };
|
||||
language_data _languageCurrent = { 0 };
|
||||
|
||||
const char **_languageOriginal = (char**)0x009BF2D4;
|
||||
|
||||
const utf8 BlackUpArrowString[] = { 0xC2, 0x8E, 0xE2, 0x96, 0xB2, 0x00 };
|
||||
const utf8 BlackDownArrowString[] = { 0xC2, 0x8E, 0xE2, 0x96, 0xBC, 0x00 };
|
||||
const utf8 BlackLeftArrowString[] = { 0xC2, 0x8E, 0xE2, 0x97, 0x80, 0x00 };
|
||||
const utf8 BlackRightArrowString[] = { 0xC2, 0x8E, 0xE2, 0x96, 0xB6, 0x00 };
|
||||
const utf8 CheckBoxMarkString[] = { 0xE2, 0x9C, 0x93, 0x00 };
|
||||
|
||||
static int language_open_file(const char *filename, language_data *language);
|
||||
static void language_close(language_data *language);
|
||||
|
||||
static int utf8_get_next(char *char_ptr, char **nextchar_ptr)
|
||||
void utf8_remove_format_codes(utf8 *text)
|
||||
{
|
||||
int result;
|
||||
int numBytes;
|
||||
|
||||
if (!(char_ptr[0] & 0x80)) {
|
||||
result = char_ptr[0];
|
||||
numBytes = 1;
|
||||
} else if (!(char_ptr[0] & 0x20)) {
|
||||
result = ((char_ptr[0] & 0x1F) << 6) | (char_ptr[1] & 0x3F);
|
||||
numBytes = 2;
|
||||
} else {
|
||||
numBytes = 1;
|
||||
utf8 *dstCh = text;
|
||||
utf8 *ch = text;
|
||||
int codepoint;
|
||||
while ((codepoint = utf8_get_next(ch, &ch)) != 0) {
|
||||
if (!utf8_is_format_code(codepoint)) {
|
||||
dstCh = utf8_write_codepoint(dstCh, codepoint);
|
||||
}
|
||||
}
|
||||
|
||||
if (nextchar_ptr != NULL)
|
||||
*nextchar_ptr = char_ptr + numBytes;
|
||||
return result;
|
||||
*dstCh = 0;
|
||||
}
|
||||
|
||||
const char *language_get_string(rct_string_id id)
|
||||
@@ -123,16 +136,30 @@ int language_open(int id)
|
||||
return 1;
|
||||
|
||||
if (id != LANGUAGE_ENGLISH_UK) {
|
||||
sprintf(filename, languagePath, gExePath, language_filenames[LANGUAGE_ENGLISH_UK]);
|
||||
sprintf(filename, languagePath, gExePath, LanguagesDescriptors[LANGUAGE_ENGLISH_UK].path);
|
||||
if (language_open_file(filename, &_languageFallback)) {
|
||||
_languageFallback.id = LANGUAGE_ENGLISH_UK;
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(filename, languagePath, gExePath, language_filenames[id]);
|
||||
sprintf(filename, languagePath, gExePath, LanguagesDescriptors[id].path);
|
||||
if (language_open_file(filename, &_languageCurrent)) {
|
||||
_languageCurrent.id = id;
|
||||
gCurrentLanguage = id;
|
||||
|
||||
if (LanguagesDescriptors[id].font == FONT_OPENRCT2_SPRITE) {
|
||||
ttf_dispose();
|
||||
gUseTrueTypeFont = false;
|
||||
gCurrentTTFFontSet = NULL;
|
||||
} else {
|
||||
ttf_dispose();
|
||||
gUseTrueTypeFont = true;
|
||||
gCurrentTTFFontSet = LanguagesDescriptors[id].font;
|
||||
if (!ttf_initialise()) {
|
||||
log_warning("Unable to initialise TrueType fonts.");
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -197,12 +224,8 @@ static int language_open_file(const char *filename, language_data *language)
|
||||
|
||||
// Handle UTF-8
|
||||
char *srcNext;
|
||||
int utf8Char = utf8_get_next(src, &srcNext);
|
||||
uint32 utf8Char = utf8_get_next(src, &srcNext);
|
||||
i += srcNext - src - 1;
|
||||
if (utf8Char > 0xFF)
|
||||
utf8Char = '?';
|
||||
else if (utf8Char > 0x7F)
|
||||
utf8Char &= 0xFF;
|
||||
|
||||
switch (mode) {
|
||||
case 0:
|
||||
@@ -233,7 +256,7 @@ static int language_open_file(const char *filename, language_data *language)
|
||||
*dst = 0;
|
||||
mode = 0;
|
||||
} else {
|
||||
*dst++ = utf8Char;
|
||||
dst = utf8_write_codepoint(dst, utf8Char);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
@@ -242,10 +265,13 @@ static int language_open_file(const char *filename, language_data *language)
|
||||
int tokenLength = min(src - token, sizeof(tokenBuffer) - 1);
|
||||
memcpy(tokenBuffer, token, tokenLength);
|
||||
tokenBuffer[tokenLength] = 0;
|
||||
char code = format_get_code(tokenBuffer);
|
||||
if (code == 0)
|
||||
uint32 code = format_get_code(tokenBuffer);
|
||||
if (code == 0) {
|
||||
code = atoi(tokenBuffer);
|
||||
*dst++ = code;
|
||||
*dst++ = code & 0xFF;
|
||||
} else {
|
||||
dst = utf8_write_codepoint(dst, code);
|
||||
}
|
||||
mode = 1;
|
||||
}
|
||||
break;
|
||||
@@ -270,56 +296,159 @@ static void language_close(language_data *language)
|
||||
}
|
||||
|
||||
const int OpenRCT2LangIdToObjectLangId[] = {
|
||||
0, 0, 1, 3, 6, 2, 0, 0, 4, 7, 5, 13
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
3,
|
||||
6,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
4,
|
||||
7,
|
||||
5,
|
||||
13
|
||||
};
|
||||
|
||||
#define STEX_BASE_STRING_ID 3447
|
||||
#define NONSTEX_BASE_STRING_ID 3463
|
||||
#define MAX_OBJECT_CACHED_STRINGS 2048
|
||||
|
||||
/* rct2: 0x0098DA16 */
|
||||
uint16 ObjectTypeStringTableCount[] = { 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3 };
|
||||
|
||||
utf8 *_cachedObjectStrings[MAX_OBJECT_CACHED_STRINGS] = { NULL };
|
||||
|
||||
void utf8_trim_string(utf8 *text)
|
||||
{
|
||||
utf8 *src = text;
|
||||
utf8 *dst = text;
|
||||
utf8 *last = text;
|
||||
int codepoint;
|
||||
|
||||
// Trim left
|
||||
while ((codepoint = utf8_get_next(src, &src)) != 0) {
|
||||
if (codepoint != ' ') {
|
||||
dst = utf8_write_codepoint(dst, codepoint);
|
||||
last = dst;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (codepoint != 0) {
|
||||
// Trim right
|
||||
while ((codepoint = utf8_get_next(src, &src)) != 0) {
|
||||
dst = utf8_write_codepoint(dst, codepoint);
|
||||
if (codepoint != ' ') {
|
||||
last = dst;
|
||||
}
|
||||
}
|
||||
}
|
||||
*last = 0;
|
||||
}
|
||||
|
||||
static wchar_t convert_specific_language_character_to_unicode(int languageId, wchar_t codepoint)
|
||||
{
|
||||
switch (languageId) {
|
||||
case RCT2_LANGUAGE_ID_KOREAN:
|
||||
return codepoint;
|
||||
case RCT2_LANGUAGE_ID_CHINESE_TRADITIONAL:
|
||||
return encoding_convert_big5_to_unicode(codepoint);
|
||||
case RCT2_LANGUAGE_ID_CHINESE_SIMPLIFIED:
|
||||
return encoding_convert_gb2312_to_unicode(codepoint);
|
||||
default:
|
||||
return codepoint;
|
||||
}
|
||||
}
|
||||
|
||||
static utf8 *convert_multibyte_charset(const char *src, int languageId)
|
||||
{
|
||||
int reservedLength = (strlen(src) * 4) + 1;
|
||||
utf8 *buffer = malloc(reservedLength);
|
||||
utf8 *dst = buffer;
|
||||
for (const uint8 *ch = src; *ch != 0;) {
|
||||
if (*ch == 0xFF) {
|
||||
ch++;
|
||||
uint8 a = *ch++;
|
||||
uint8 b = *ch++;
|
||||
uint16 codepoint = (a << 8) | b;
|
||||
|
||||
codepoint = convert_specific_language_character_to_unicode(languageId, codepoint);
|
||||
dst = utf8_write_codepoint(dst, codepoint);
|
||||
} else {
|
||||
dst = utf8_write_codepoint(dst, *ch++);
|
||||
}
|
||||
}
|
||||
*dst++ = 0;
|
||||
int actualLength = dst - buffer;
|
||||
buffer = realloc(buffer, actualLength);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static bool rct2_language_is_multibyte_charset(int languageId)
|
||||
{
|
||||
switch (languageId) {
|
||||
case RCT2_LANGUAGE_ID_KOREAN:
|
||||
case RCT2_LANGUAGE_ID_CHINESE_TRADITIONAL:
|
||||
case RCT2_LANGUAGE_ID_CHINESE_SIMPLIFIED:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* rct2: 0x006A9E24*/
|
||||
rct_string_id object_get_localised_text(uint8_t** pStringTable/*ebp*/, int type/*ecx*/, int index/*ebx*/, int tableindex/*edx*/)
|
||||
{
|
||||
char* pString = NULL;
|
||||
uint8 languageId, chosenLanguageId;
|
||||
char *pString = NULL;
|
||||
int result = 0;
|
||||
while (true)
|
||||
{
|
||||
uint8_t language_code = *(*pStringTable)++;
|
||||
|
||||
if (language_code == 0xFF) //end of string table
|
||||
break;
|
||||
bool isBlank;
|
||||
|
||||
while ((languageId = *(*pStringTable)++) != RCT2_LANGUAGE_ID_END) {
|
||||
isBlank = true;
|
||||
|
||||
// Strings that are just ' ' are set as invalid langauges.
|
||||
// But if there is no real string then it will set the string as
|
||||
// the blank string
|
||||
for (char *ch = *pStringTable; *ch != 0; ch++) {
|
||||
if (!isblank(*ch)) {
|
||||
isBlank = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isBlank) languageId = 0xFE;
|
||||
|
||||
// This is the ideal situation. Language found
|
||||
if (language_code == OpenRCT2LangIdToObjectLangId[gCurrentLanguage])//1)
|
||||
{
|
||||
if (languageId == LanguagesDescriptors[gCurrentLanguage].rct2_original_id) {
|
||||
chosenLanguageId = languageId;
|
||||
pString = *pStringTable;
|
||||
result |= 1;
|
||||
}
|
||||
|
||||
// Just in case always load english into pString
|
||||
if (language_code == 0 && !(result & 1))
|
||||
{
|
||||
if (languageId == RCT2_LANGUAGE_ID_ENGLISH_UK && !(result & 1)) {
|
||||
chosenLanguageId = languageId;
|
||||
pString = *pStringTable;
|
||||
result |= 2;
|
||||
}
|
||||
|
||||
// Failing that fall back to whatever is first string
|
||||
if (!(result & 7))
|
||||
{
|
||||
if (!(result & 7)) {
|
||||
chosenLanguageId = languageId;
|
||||
pString = *pStringTable;
|
||||
result |= 4;
|
||||
if (!isBlank) result |= 4;
|
||||
}
|
||||
|
||||
// Skip over the actual string entry to get to the next
|
||||
// entry
|
||||
// Skip over the actual string entry to get to the next entry
|
||||
while (*(*pStringTable)++ != 0);
|
||||
}
|
||||
|
||||
// If not scenario text
|
||||
if (RCT2_GLOBAL(0x9ADAFC, uint8_t) == 0)
|
||||
{
|
||||
int stringid = 3463;
|
||||
for (int i = 0; i < type; i++)
|
||||
{
|
||||
if (RCT2_GLOBAL(0x009ADAFC, uint8) == 0) {
|
||||
int stringid = NONSTEX_BASE_STRING_ID;
|
||||
for (int i = 0; i < type; i++) {
|
||||
int nrobjects = object_entry_group_counts[i];
|
||||
int nrstringtables = ObjectTypeStringTableCount[i];
|
||||
stringid += nrobjects * nrstringtables;
|
||||
@@ -329,23 +458,48 @@ rct_string_id object_get_localised_text(uint8_t** pStringTable/*ebp*/, int type/
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURR_OBJECT_BASE_STRING_ID, uint32) = stringid;
|
||||
stringid += tableindex;
|
||||
|
||||
// cache UTF-8 string
|
||||
int cacheStringOffset = stringid - STEX_BASE_STRING_ID;
|
||||
utf8 **cacheString = &_cachedObjectStrings[cacheStringOffset];
|
||||
if (*cacheString != NULL) {
|
||||
free(*cacheString);
|
||||
}
|
||||
if (rct2_language_is_multibyte_charset(chosenLanguageId)) {
|
||||
*cacheString = convert_multibyte_charset(pString, chosenLanguageId);
|
||||
} else {
|
||||
*cacheString = win1252_to_utf8_alloc(pString);
|
||||
}
|
||||
utf8_trim_string(*cacheString);
|
||||
|
||||
//put pointer in stringtable
|
||||
if (_languageCurrent.num_strings > stringid)
|
||||
_languageCurrent.strings[stringid] = pString;
|
||||
_languageCurrent.strings[stringid] = *cacheString;
|
||||
// Until all string related functions are finished copy
|
||||
// to old array as well.
|
||||
_languageOriginal[stringid] = pString;
|
||||
_languageOriginal[stringid] = *cacheString;
|
||||
return stringid;
|
||||
}
|
||||
else
|
||||
{
|
||||
int stringid = 3447 + tableindex;
|
||||
} else {
|
||||
int stringid = STEX_BASE_STRING_ID + tableindex;
|
||||
|
||||
// cache UTF-8 string
|
||||
int cacheStringOffset = stringid - STEX_BASE_STRING_ID;
|
||||
utf8 **cacheString = &_cachedObjectStrings[cacheStringOffset];
|
||||
if (*cacheString != NULL) {
|
||||
free(*cacheString);
|
||||
}
|
||||
if (rct2_language_is_multibyte_charset(chosenLanguageId)) {
|
||||
*cacheString = convert_multibyte_charset(pString, chosenLanguageId);
|
||||
} else {
|
||||
*cacheString = win1252_to_utf8_alloc(pString);
|
||||
}
|
||||
utf8_trim_string(*cacheString);
|
||||
|
||||
//put pointer in stringtable
|
||||
if (_languageCurrent.num_strings > stringid)
|
||||
_languageCurrent.strings[stringid] = pString;
|
||||
_languageCurrent.strings[stringid] = *cacheString;
|
||||
// Until all string related functions are finished copy
|
||||
// to old array as well.
|
||||
_languageOriginal[stringid] = pString;
|
||||
_languageOriginal[stringid] = *cacheString;
|
||||
return stringid;
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@
|
||||
#define _LANGUAGE_H_
|
||||
|
||||
#include "../common.h"
|
||||
#include "../drawing/font.h"
|
||||
|
||||
enum {
|
||||
LANGUAGE_UNDEFINED,
|
||||
@@ -36,11 +37,32 @@ enum {
|
||||
LANGUAGE_SWEDISH,
|
||||
LANGUAGE_ITALIAN,
|
||||
LANGUAGE_PORTUGUESE_BR,
|
||||
LANGUAGE_CHINESE_TRADITIONAL,
|
||||
// LANGUAGE_KOREAN,
|
||||
LANGUAGE_COUNT
|
||||
};
|
||||
|
||||
extern const char *language_names[LANGUAGE_COUNT];
|
||||
#define FONT_OPENRCT2_SPRITE NULL
|
||||
|
||||
typedef struct {
|
||||
const char *locale;
|
||||
const utf8 *english_name;
|
||||
const utf8 *native_name;
|
||||
const utf8 *path;
|
||||
TTFFontSetDescriptor *font;
|
||||
uint8 rct2_original_id;
|
||||
} language_descriptor;
|
||||
|
||||
extern const language_descriptor LanguagesDescriptors[LANGUAGE_COUNT];
|
||||
|
||||
extern int gCurrentLanguage;
|
||||
extern bool gUseTrueTypeFont;
|
||||
|
||||
extern const utf8 BlackUpArrowString[];
|
||||
extern const utf8 BlackDownArrowString[];
|
||||
extern const utf8 BlackLeftArrowString[];
|
||||
extern const utf8 BlackRightArrowString[];
|
||||
extern const utf8 CheckBoxMarkString[];
|
||||
|
||||
const char *language_get_string(rct_string_id id);
|
||||
int language_open(int id);
|
||||
@@ -48,4 +70,11 @@ void language_close_all();
|
||||
|
||||
rct_string_id object_get_localised_text(uint8_t** pStringTable/*ebp*/, int type/*ecx*/, int index/*ebx*/, int tableindex/*edx*/);
|
||||
|
||||
uint32 utf8_get_next(const utf8 *char_ptr, const utf8 **nextchar_ptr);
|
||||
utf8 *utf8_write_codepoint(utf8 *dst, uint32 codepoint);
|
||||
int utf8_insert_codepoint(utf8 *dst, uint32 codepoint);
|
||||
bool utf8_is_codepoint_start(utf8 *text);
|
||||
void utf8_remove_format_codes(utf8 *text);
|
||||
int utf8_get_codepoint_length(int codepoint);
|
||||
|
||||
#endif
|
||||
+103
-62
@@ -29,8 +29,8 @@
|
||||
#pragma region Format codes
|
||||
|
||||
typedef struct {
|
||||
char code;
|
||||
char *token;
|
||||
uint32 code;
|
||||
const char *token;
|
||||
} format_code_token;
|
||||
|
||||
format_code_token format_code_tokens[] = {
|
||||
@@ -107,7 +107,7 @@ format_code_token format_code_tokens[] = {
|
||||
{ FORMAT_INVERTEDQUESTION, "INVERTEDQUESTION" }
|
||||
};
|
||||
|
||||
char format_get_code(const char *token)
|
||||
uint32 format_get_code(const char *token)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < countof(format_code_tokens); i++)
|
||||
@@ -116,7 +116,7 @@ char format_get_code(const char *token)
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *format_get_token(char code)
|
||||
const char *format_get_token(uint32 code)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < countof(format_code_tokens); i++)
|
||||
@@ -125,6 +125,52 @@ const char *format_get_token(char code)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool utf8_is_format_code(int codepoint)
|
||||
{
|
||||
if (codepoint < 32) return true;
|
||||
if (codepoint >= FORMAT_ARGUMENT_CODE_START && codepoint <= FORMAT_ARGUMENT_CODE_END) return true;
|
||||
if (codepoint >= FORMAT_COLOUR_CODE_START && codepoint <= FORMAT_COLOUR_CODE_END) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool utf8_should_use_sprite_for_codepoint(int codepoint)
|
||||
{
|
||||
switch (codepoint) {
|
||||
case FORMAT_UP:
|
||||
case FORMAT_DOWN:
|
||||
case FORMAT_LEFTGUILLEMET:
|
||||
case FORMAT_TICK:
|
||||
case FORMAT_CROSS:
|
||||
case FORMAT_RIGHT:
|
||||
case FORMAT_RIGHTGUILLEMET:
|
||||
case FORMAT_SMALLUP:
|
||||
case FORMAT_SMALLDOWN:
|
||||
case FORMAT_LEFT:
|
||||
case FORMAT_OPENQUOTES:
|
||||
case FORMAT_ENDQUOTES:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int utf8_get_format_code_arg_length(int codepoint)
|
||||
{
|
||||
switch (codepoint) {
|
||||
case FORMAT_MOVE_X:
|
||||
case FORMAT_ADJUST_PALETTE:
|
||||
case 3:
|
||||
case 4:
|
||||
return 1;
|
||||
case FORMAT_NEWLINE_X_Y:
|
||||
return 2;
|
||||
case FORMAT_INLINE_SPRITE:
|
||||
return 4;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
void format_string_part_from_raw(char **dest, const char *src, char **args);
|
||||
@@ -312,7 +358,7 @@ void format_currency(char **dest, long long value)
|
||||
}
|
||||
|
||||
// Currency symbol
|
||||
const char *symbol = currencySpec->symbol;
|
||||
const utf8 *symbol = currencySpec->symbol;
|
||||
|
||||
// Prefix
|
||||
if (currencySpec->affix == CURRENCY_PREFIX) {
|
||||
@@ -343,7 +389,7 @@ void format_currency_2dp(char **dest, long long value)
|
||||
}
|
||||
|
||||
// Currency symbol
|
||||
const char *symbol = currencySpec->symbol;
|
||||
const utf8 *symbol = currencySpec->symbol;
|
||||
|
||||
// Prefix
|
||||
if (currencySpec->affix == CURRENCY_PREFIX) {
|
||||
@@ -579,11 +625,11 @@ void format_string_code(unsigned char format_code, char **dest, char **args)
|
||||
}
|
||||
}
|
||||
|
||||
void format_string_part_from_raw(char **dest, const char *src, char **args)
|
||||
void format_string_part_from_raw(utf8 **dest, const utf8 *src, char **args)
|
||||
{
|
||||
unsigned char code;
|
||||
unsigned int code;
|
||||
while (1) {
|
||||
code = *src++;
|
||||
code = utf8_get_next(src, &src);
|
||||
if (code < ' ') {
|
||||
if (code == 0) {
|
||||
*(*dest)++ = code;
|
||||
@@ -609,12 +655,12 @@ void format_string_part_from_raw(char **dest, const char *src, char **args)
|
||||
} else if (code < 142) {
|
||||
format_string_code(code, dest, args);
|
||||
} else {
|
||||
*(*dest)++ = code;
|
||||
*dest = utf8_write_codepoint(*dest, code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void format_string_part(char **dest, rct_string_id format, char **args)
|
||||
void format_string_part(utf8 **dest, rct_string_id format, char **args)
|
||||
{
|
||||
if (format == (rct_string_id)STR_NONE) {
|
||||
**dest = 0;
|
||||
@@ -654,12 +700,12 @@ void format_string_part(char **dest, rct_string_id format, char **args)
|
||||
* format (ax)
|
||||
* args (ecx)
|
||||
*/
|
||||
void format_string(char *dest, rct_string_id format, void *args)
|
||||
void format_string(utf8 *dest, rct_string_id format, void *args)
|
||||
{
|
||||
format_string_part(&dest, format, (char**)&args);
|
||||
}
|
||||
|
||||
void format_string_raw(char *dest, char *src, void *args)
|
||||
void format_string_raw(utf8 *dest, utf8 *src, void *args)
|
||||
{
|
||||
format_string_part_from_raw(&dest, src, (char**)&args);
|
||||
}
|
||||
@@ -671,7 +717,7 @@ void format_string_raw(char *dest, char *src, void *args)
|
||||
* format (ax)
|
||||
* args (ecx)
|
||||
*/
|
||||
void format_string_to_upper(char *dest, rct_string_id format, void *args)
|
||||
void format_string_to_upper(utf8 *dest, rct_string_id format, void *args)
|
||||
{
|
||||
format_string(dest, format, args);
|
||||
|
||||
@@ -738,58 +784,53 @@ void generate_string_file()
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the length of the string in buffer.
|
||||
* note you can't use strlen as there can be inline sprites!
|
||||
*
|
||||
* buffer (esi)
|
||||
*/
|
||||
int get_string_length(char* buffer)
|
||||
* Returns a pointer to the null terminator of the given UTF-8 string.
|
||||
*/
|
||||
utf8 *get_string_end(const utf8 *text)
|
||||
{
|
||||
// Length of string
|
||||
int length = 0;
|
||||
int codepoint;
|
||||
const utf8 *ch = text;
|
||||
|
||||
for (uint8* curr_char = (uint8*)buffer; *curr_char != (uint8)0; curr_char++) {
|
||||
length++;
|
||||
if (*curr_char >= 0x20) {
|
||||
continue;
|
||||
}
|
||||
switch (*curr_char) {
|
||||
case FORMAT_MOVE_X:
|
||||
case FORMAT_ADJUST_PALETTE:
|
||||
case 3:
|
||||
case 4:
|
||||
curr_char++;
|
||||
length++;
|
||||
break;
|
||||
case FORMAT_NEWLINE:
|
||||
case FORMAT_NEWLINE_SMALLER:
|
||||
case FORMAT_TINYFONT:
|
||||
case FORMAT_BIGFONT:
|
||||
case FORMAT_MEDIUMFONT:
|
||||
case FORMAT_SMALLFONT:
|
||||
case FORMAT_OUTLINE:
|
||||
case FORMAT_OUTLINE_OFF:
|
||||
case FORMAT_WINDOW_COLOUR_1:
|
||||
case FORMAT_WINDOW_COLOUR_2:
|
||||
case FORMAT_WINDOW_COLOUR_3:
|
||||
case 0x10:
|
||||
continue;
|
||||
case FORMAT_INLINE_SPRITE:
|
||||
length += 4;
|
||||
curr_char += 4;
|
||||
break;
|
||||
default:
|
||||
if (*curr_char <= 0x16) { //case 0x11? FORMAT_NEW_LINE_X_Y
|
||||
length += 2;
|
||||
curr_char += 2;
|
||||
continue;
|
||||
}
|
||||
length += 4;
|
||||
curr_char += 4;//never happens?
|
||||
break;
|
||||
while ((codepoint = utf8_get_next(ch, &ch)) != 0) {
|
||||
int argLength = utf8_get_format_code_arg_length(codepoint);
|
||||
ch += argLength;
|
||||
}
|
||||
return (utf8*)(ch - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of bytes (including the null terminator) in the given UTF-8 string.
|
||||
*/
|
||||
size_t get_string_size(const utf8 *text)
|
||||
{
|
||||
return get_string_end(text) - text + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of visible characters (excludes format codes) in the given UTF-8 string.
|
||||
*/
|
||||
int get_string_length(const utf8 *text)
|
||||
{
|
||||
int codepoint;
|
||||
const utf8 *ch = text;
|
||||
|
||||
int count = 0;
|
||||
while ((codepoint = utf8_get_next(ch, &ch)) != 0) {
|
||||
if (utf8_is_format_code(codepoint)) {
|
||||
ch += utf8_get_format_code_arg_length(codepoint);
|
||||
} else {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return length;
|
||||
return count;
|
||||
}
|
||||
|
||||
utf8 *win1252_to_utf8_alloc(const char *src)
|
||||
{
|
||||
int reservedSpace = (strlen(src) * 4) + 1;
|
||||
utf8 *result = malloc(reservedSpace);
|
||||
int actualSpace = win1252_to_utf8(result, src, reservedSpace);
|
||||
return (utf8*)realloc(result, actualSpace);
|
||||
}
|
||||
|
||||
int win1252_to_utf8(utf8string dst, const char *src, int maxBufferLength)
|
||||
|
||||
@@ -26,20 +26,35 @@
|
||||
#include "language.h"
|
||||
#include "string_ids.h"
|
||||
|
||||
bool utf8_is_format_code(int codepoint);
|
||||
bool utf8_should_use_sprite_for_codepoint(int codepoint);
|
||||
int font_sprite_get_codepoint_offset(int codepoint);
|
||||
int utf8_get_format_code_arg_length(int codepoint);
|
||||
|
||||
void format_string(char *dest, rct_string_id format, void *args);
|
||||
void format_string_raw(char *dest, char *src, void *args);
|
||||
void format_string_to_upper(char *dest, rct_string_id format, void *args);
|
||||
void generate_string_file();
|
||||
void error_string_quit(int error, rct_string_id format);
|
||||
int get_string_length(char* buffer);
|
||||
utf8 *get_string_end(const utf8 *text);
|
||||
size_t get_string_size(const utf8 *text);
|
||||
int get_string_length(const utf8 *text);
|
||||
|
||||
void user_string_clear_all();
|
||||
rct_string_id user_string_allocate(int base, const char *text);
|
||||
rct_string_id user_string_allocate(int base, const utf8 *text);
|
||||
void user_string_free(rct_string_id id);
|
||||
bool is_user_string_id(rct_string_id stringId);
|
||||
|
||||
utf8 *win1252_to_utf8_alloc(const char *src);
|
||||
int win1252_to_utf8(utf8string dst, const char *src, int maxBufferLength);
|
||||
|
||||
int rct2_to_utf8(utf8 *dst, const char *src);
|
||||
int utf8_to_rct2(char *dst, const utf8 *src);
|
||||
wchar_t encoding_convert_rct2_to_unicode(wchar_t rct2str);
|
||||
wchar_t encoding_convert_unicode_to_rct2(wchar_t unicode);
|
||||
wchar_t encoding_convert_gb2312_to_unicode(wchar_t gb2312);
|
||||
wchar_t encoding_convert_big5_to_unicode(wchar_t big5);
|
||||
|
||||
#define MAX_USER_STRINGS 1024
|
||||
#define USER_STRING_MAX_LENGTH 32
|
||||
|
||||
@@ -47,4 +62,6 @@ int win1252_to_utf8(utf8string dst, const char *src, int maxBufferLength);
|
||||
extern const char real_name_initials[16];
|
||||
extern const char *real_names[1024];
|
||||
|
||||
extern utf8 *gUserStrings;
|
||||
|
||||
#endif
|
||||
@@ -1825,6 +1825,8 @@ enum {
|
||||
STR_X_WEEKS_REMAINING = 5483,
|
||||
STR_1_WEEK_REMAINING = 5484,
|
||||
|
||||
STR_LAND_TOOL_SIZE_VALUE = 5486,
|
||||
|
||||
// Have to include resource strings (from scenarios and objects) for the time being now that language is partially working
|
||||
STR_COUNT = 32768
|
||||
};
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "../addresses.h"
|
||||
#include "localisation.h"
|
||||
|
||||
char *gUserStrings = (char*)0x0135A8F4;
|
||||
utf8 *gUserStrings = (char*)0x0135A8F4;
|
||||
|
||||
static bool user_string_exists(const char *text);
|
||||
|
||||
@@ -38,7 +38,7 @@ void user_string_clear_all()
|
||||
*
|
||||
* rct2: 0x006C421D
|
||||
*/
|
||||
rct_string_id user_string_allocate(int base, const char *text)
|
||||
rct_string_id user_string_allocate(int base, const utf8 *text)
|
||||
{
|
||||
int highBits = (base & 0x7F) << 9;
|
||||
bool allowDuplicates = base & 0x80;
|
||||
@@ -73,7 +73,7 @@ void user_string_free(rct_string_id id)
|
||||
gUserStrings[id * USER_STRING_MAX_LENGTH] = 0;
|
||||
}
|
||||
|
||||
static bool user_string_exists(const char *text)
|
||||
static bool user_string_exists(const utf8 *text)
|
||||
{
|
||||
char *userString = gUserStrings;
|
||||
for (int i = 0; i < MAX_USER_STRINGS; i++, userString += USER_STRING_MAX_LENGTH) {
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
#include "localisation.h"
|
||||
|
||||
uint32 utf8_get_next(const utf8 *char_ptr, const utf8 **nextchar_ptr)
|
||||
{
|
||||
int result;
|
||||
int numBytes;
|
||||
|
||||
if (!(char_ptr[0] & 0x80)) {
|
||||
result = char_ptr[0];
|
||||
numBytes = 1;
|
||||
} else if ((char_ptr[0] & 0xE0) == 0xC0) {
|
||||
result = ((char_ptr[0] & 0x1F) << 6) | (char_ptr[1] & 0x3F);
|
||||
numBytes = 2;
|
||||
} else if ((char_ptr[0] & 0xF0) == 0xE0) {
|
||||
result = ((char_ptr[0] & 0x0F) << 12) | ((char_ptr[1] & 0x3F) << 6) | (char_ptr[2] & 0x3F);
|
||||
numBytes = 3;
|
||||
} else if ((char_ptr[0] & 0xF8) == 0xF0) {
|
||||
result = ((char_ptr[0] & 0x07) << 18) | ((char_ptr[1] & 0x3F) << 12) | ((char_ptr[1] & 0x3F) << 6) | (char_ptr[2] & 0x3F);
|
||||
numBytes = 4;
|
||||
} else {
|
||||
// TODO 4 bytes
|
||||
result = ' ';
|
||||
numBytes = 1;
|
||||
}
|
||||
|
||||
if (nextchar_ptr != NULL)
|
||||
*nextchar_ptr = char_ptr + numBytes;
|
||||
return result;
|
||||
}
|
||||
|
||||
utf8 *utf8_write_codepoint(utf8 *dst, uint32 codepoint)
|
||||
{
|
||||
if (codepoint <= 0x7F) {
|
||||
dst[0] = (utf8)codepoint;
|
||||
return dst + 1;
|
||||
} else if (codepoint <= 0x7FF) {
|
||||
dst[0] = 0xC0 | ((codepoint >> 6) & 0x1F);
|
||||
dst[1] = 0x80 | (codepoint & 0x3F);
|
||||
return dst + 2;
|
||||
} else if (codepoint <= 0xFFFF) {
|
||||
dst[0] = 0xE0 | ((codepoint >> 12) & 0x0F);
|
||||
dst[1] = 0x80 | ((codepoint >> 6) & 0x3F);
|
||||
dst[2] = 0x80 | (codepoint & 0x3F);
|
||||
return dst + 3;
|
||||
} else {
|
||||
dst[0] = 0xF0 | ((codepoint >> 18) & 0x07);
|
||||
dst[1] = 0x80 | ((codepoint >> 12) & 0x3F);
|
||||
dst[2] = 0x80 | ((codepoint >> 6) & 0x3F);
|
||||
dst[3] = 0x80 | (codepoint & 0x3F);
|
||||
return dst + 4;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts the given codepoint at the given address, shifting all characters after along.
|
||||
* @returns the size of the inserted codepoint.
|
||||
*/
|
||||
int utf8_insert_codepoint(utf8 *dst, uint32 codepoint)
|
||||
{
|
||||
int shift = utf8_get_codepoint_length(codepoint);
|
||||
utf8 *endPoint = get_string_end(dst);
|
||||
memmove(dst + shift, dst, endPoint - dst + 1);
|
||||
utf8_write_codepoint(dst, codepoint);
|
||||
return shift;
|
||||
}
|
||||
|
||||
bool utf8_is_codepoint_start(utf8 *text)
|
||||
{
|
||||
if ((text[0] & 0x80) == 0) return true;
|
||||
if ((text[0] & 0xC0) == 0xC0) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
int utf8_get_codepoint_length(int codepoint)
|
||||
{
|
||||
if (codepoint <= 0x7F) {
|
||||
return 1;
|
||||
} else if (codepoint <= 0x7FF) {
|
||||
return 2;
|
||||
} else if (codepoint <= 0xFFFF) {
|
||||
return 3;
|
||||
} else {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
+41
-49
@@ -32,31 +32,27 @@ rct_news_item *gNewsItems = RCT2_ADDRESS(RCT2_ADDRESS_NEWS_ITEM_LIST, rct_news_i
|
||||
void window_game_bottom_toolbar_invalidate_news_item();
|
||||
static int news_item_get_new_history_slot();
|
||||
|
||||
#define MAX_NEWS 60
|
||||
|
||||
bool news_item_is_valid_idx(const uint8 idx)
|
||||
bool news_item_is_valid_idx(int index)
|
||||
{
|
||||
if (idx > MAX_NEWS)
|
||||
{
|
||||
if (index > MAX_NEWS_ITEMS) {
|
||||
log_error("Tried to get news item past MAX_NEWS.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
rct_news_item *news_item_get(const uint8 idx)
|
||||
rct_news_item *news_item_get(int index)
|
||||
{
|
||||
if (news_item_is_valid_idx(idx))
|
||||
{
|
||||
return &gNewsItems[idx];
|
||||
if (news_item_is_valid_idx(index)) {
|
||||
return &gNewsItems[index];
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool news_item_is_empty(const uint8 idx)
|
||||
bool news_item_is_empty(int index)
|
||||
{
|
||||
return news_item_get(idx)->type == NEWS_ITEM_NULL;
|
||||
return news_item_get(index)->type == NEWS_ITEM_NULL;
|
||||
}
|
||||
|
||||
bool news_item_is_queue_empty()
|
||||
@@ -179,7 +175,7 @@ void news_item_close_current()
|
||||
newsItems[i] = newsItems[0];
|
||||
|
||||
// Set the end of the end of the history list
|
||||
if (i < MAX_NEWS)
|
||||
if (i < MAX_NEWS_ITEMS)
|
||||
newsItems[i + 1].type = NEWS_ITEM_NULL;
|
||||
|
||||
// Invalidate the news window
|
||||
@@ -198,7 +194,7 @@ static void news_item_shift_history_up()
|
||||
{
|
||||
const int history_idx = 11;
|
||||
rct_news_item *history_start = news_item_get(history_idx);
|
||||
const size_t count = sizeof(rct_news_item) * (MAX_NEWS - 1 - history_idx);
|
||||
const size_t count = sizeof(rct_news_item) * (MAX_NEWS_ITEMS - 1 - history_idx);
|
||||
memmove(history_start, history_start + 1, count);
|
||||
}
|
||||
|
||||
@@ -212,13 +208,13 @@ static int news_item_get_new_history_slot()
|
||||
int i;
|
||||
|
||||
// Find an available history news item slot
|
||||
for (i = 11; i <= MAX_NEWS; i++)
|
||||
for (i = 11; i <= MAX_NEWS_ITEMS; i++)
|
||||
if (news_item_is_empty(i))
|
||||
return i;
|
||||
|
||||
// Dequeue the first history news item, shift history up
|
||||
news_item_shift_history_up();
|
||||
return MAX_NEWS;
|
||||
return MAX_NEWS_ITEMS;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -301,14 +297,14 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int *
|
||||
**/
|
||||
void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc)
|
||||
{
|
||||
char *buffer = (char*)0x0141EF68;
|
||||
utf8 *buffer = (char*)0x0141EF68;
|
||||
void *args = (void*)0x013CE952;
|
||||
|
||||
format_string(buffer, string_id, args); // overflows possible?
|
||||
news_item_add_to_queue_raw(type, buffer, assoc);
|
||||
}
|
||||
|
||||
void news_item_add_to_queue_raw(uint8 type, const char *text, uint32 assoc)
|
||||
void news_item_add_to_queue_raw(uint8 type, const utf8 *text, uint32 assoc)
|
||||
{
|
||||
int i = 0;
|
||||
rct_news_item *newsItem = RCT2_ADDRESS(RCT2_ADDRESS_NEWS_ITEM_LIST, rct_news_item);
|
||||
@@ -328,8 +324,7 @@ void news_item_add_to_queue_raw(uint8 type, const char *text, uint32 assoc)
|
||||
newsItem->ticks = 0;
|
||||
newsItem->month_year = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16);
|
||||
newsItem->day = ((days_in_month[(newsItem->month_year & 7)] * RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16)) >> 16) + 1;
|
||||
newsItem->colour = text[0];
|
||||
strncpy(newsItem->text, text + 1, 254);
|
||||
strncpy(newsItem->text, text, 255);
|
||||
newsItem->text[254] = 0;
|
||||
|
||||
// blatant disregard for what happens on the last element.
|
||||
@@ -406,39 +401,36 @@ void news_item_open_subject(int type, int subject)
|
||||
}
|
||||
|
||||
/**
|
||||
* rct2: 0x0066E407
|
||||
*
|
||||
* rct2: 0x0066E407
|
||||
*/
|
||||
void news_item_disable_news(uint8 type, uint32 assoc) {
|
||||
// TODO: write test invalidating windows
|
||||
int i;
|
||||
for (i = 0; i < 11; i++)
|
||||
{
|
||||
if (!news_item_is_empty(i))
|
||||
{
|
||||
rct_news_item * const newsItem = news_item_get(i);
|
||||
if (type == newsItem->type && assoc == newsItem->assoc) {
|
||||
newsItem->flags |= 0x1;
|
||||
if (i == 0) {
|
||||
window_game_bottom_toolbar_invalidate_news_item();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
void news_item_disable_news(uint8 type, uint32 assoc)
|
||||
{
|
||||
// TODO: write test invalidating windows
|
||||
for (int i = 0; i < 11; i++) {
|
||||
if (!news_item_is_empty(i)) {
|
||||
rct_news_item * const newsItem = news_item_get(i);
|
||||
if (type == newsItem->type && assoc == newsItem->assoc) {
|
||||
newsItem->flags |= 0x1;
|
||||
if (i == 0) {
|
||||
window_game_bottom_toolbar_invalidate_news_item();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 11; i <= MAX_NEWS; i++)
|
||||
{
|
||||
if (!news_item_is_empty(i))
|
||||
{
|
||||
rct_news_item * const newsItem = news_item_get(i);
|
||||
if (type == newsItem->type && assoc == newsItem->assoc) {
|
||||
newsItem->flags |= 0x1;
|
||||
window_invalidate_by_class(WC_RECENT_NEWS);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
for (int i = 11; i <= MAX_NEWS_ITEMS; i++) {
|
||||
if (!news_item_is_empty(i)) {
|
||||
rct_news_item * const newsItem = news_item_get(i);
|
||||
if (type == newsItem->type && assoc == newsItem->assoc) {
|
||||
newsItem->flags |= 0x1;
|
||||
window_invalidate_by_class(WC_RECENT_NEWS);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,21 +48,22 @@ typedef struct {
|
||||
uint16 month_year; // 0x08
|
||||
uint8 day; // 0x0A
|
||||
uint8 pad_0B; // 0x0B
|
||||
uint8 colour; // 0x0C
|
||||
char text[255]; // 0x0D
|
||||
utf8 text[256]; // 0x0C
|
||||
} rct_news_item;
|
||||
|
||||
#define MAX_NEWS_ITEMS 60
|
||||
|
||||
void news_item_init_queue();
|
||||
void news_item_update_current();
|
||||
void news_item_close_current();
|
||||
void news_item_get_subject_location(int type, int subject, int *x, int *y, int *z);
|
||||
void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc);
|
||||
void news_item_add_to_queue_raw(uint8 type, const char *text, uint32 assoc);
|
||||
void news_item_add_to_queue_raw(uint8 type, const utf8 *text, uint32 assoc);
|
||||
void news_item_open_subject(int type, int subject);
|
||||
void news_item_disable_news(uint8 type, uint32 assoc);
|
||||
rct_news_item *news_item_get(const uint8 idx);
|
||||
bool news_item_is_empty(const uint8 idx);
|
||||
rct_news_item *news_item_get(int index);
|
||||
bool news_item_is_empty(int index);
|
||||
bool news_item_is_queue_empty();
|
||||
bool news_item_is_valid_idx(const uint8 idx);
|
||||
bool news_item_is_valid_idx(int index);
|
||||
|
||||
#endif
|
||||
+19
-17
@@ -39,8 +39,8 @@
|
||||
#include "world/mapgen.h"
|
||||
|
||||
int gOpenRCT2StartupAction = STARTUP_ACTION_TITLE;
|
||||
char gOpenRCT2StartupActionPath[512] = { 0 };
|
||||
char gExePath[MAX_PATH];
|
||||
utf8 gOpenRCT2StartupActionPath[512] = { 0 };
|
||||
utf8 gExePath[MAX_PATH];
|
||||
|
||||
// This should probably be changed later and allow a custom selection of things to initialise like SDL_INIT
|
||||
bool gOpenRCT2Headless = false;
|
||||
@@ -112,19 +112,18 @@ static void openrct2_copy_files_over(const char *originalDirectory, const char *
|
||||
|
||||
static void openrct2_set_exe_path()
|
||||
{
|
||||
char exePath[MAX_PATH];
|
||||
char tempPath[MAX_PATH];
|
||||
char *exeDelimiter;
|
||||
int pathEnd;
|
||||
wchar_t exePath[MAX_PATH];
|
||||
wchar_t tempPath[MAX_PATH];
|
||||
wchar_t *exeDelimiter;
|
||||
int exeDelimiterIndex;
|
||||
|
||||
GetModuleFileName(NULL, exePath, MAX_PATH);
|
||||
exeDelimiter = strrchr(exePath, platform_get_path_separator());
|
||||
GetModuleFileNameW(NULL, exePath, MAX_PATH);
|
||||
exeDelimiter = wcsrchr(exePath, platform_get_path_separator());
|
||||
exeDelimiterIndex = (int)(exeDelimiter - exePath);
|
||||
pathEnd = strlen(exePath) - (strlen(exePath) - exeDelimiterIndex);
|
||||
strncpy(tempPath, exePath, pathEnd);
|
||||
tempPath[pathEnd] = '\0';
|
||||
_fullpath(gExePath, tempPath, MAX_PATH);
|
||||
lstrcpynW(tempPath, exePath, exeDelimiterIndex + 1);
|
||||
tempPath[exeDelimiterIndex] = L'\0';
|
||||
_wfullpath(exePath, tempPath, MAX_PATH);
|
||||
WideCharToMultiByte(CP_UTF8, 0, exePath, countof(exePath), gExePath, countof(gExePath), NULL, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,11 +187,14 @@ bool openrct2_initialise()
|
||||
title_sequences_load_presets();
|
||||
|
||||
// Hooks to allow RCT2 to call OpenRCT2 functions instead
|
||||
addhook(0x006E732D, (int)gfx_set_dirty_blocks, 0, (int[]){ EAX, EBX, EDX, EBP, END }, 0); // remove when all callers are decompiled
|
||||
addhook(0x006E7499, (int)gfx_redraw_screen_rect, 0, (int[]){ EAX, EBX, EDX, EBP, END }, 0); // remove when 0x6E7FF3 is decompiled
|
||||
addhook(0x006B752C, (int)ride_crash, 0, (int[]){ EDX, EBX, END }, 0); // remove when all callers are decompiled
|
||||
addhook(0x0069A42F, (int)peep_window_state_update, 0, (int[]){ ESI, END }, 0); // remove when all callers are decompiled
|
||||
addhook(0x006BB76E, (int)sound_play_panned, 0, (int[]){EAX, EBX, ECX, EDX, EBP, END}, EAX); // remove when all callers are decompiled
|
||||
addhook(0x006E732D, (int)gfx_set_dirty_blocks, 0, (int[]){ EAX, EBX, EDX, EBP, END }, 0, 0); // remove when all callers are decompiled
|
||||
addhook(0x006E7499, (int)gfx_redraw_screen_rect, 0, (int[]){ EAX, EBX, EDX, EBP, END }, 0, 0); // remove when 0x6E7FF3 is decompiled
|
||||
addhook(0x006B752C, (int)ride_crash, 0, (int[]){ EDX, EBX, END }, 0, 0); // remove when all callers are decompiled
|
||||
addhook(0x0069A42F, (int)peep_window_state_update, 0, (int[]){ ESI, END }, 0, 0); // remove when all callers are decompiled
|
||||
addhook(0x006BB76E, (int)sound_play_panned, 0, (int[]){EAX, EBX, ECX, EDX, EBP, END}, EAX, 0); // remove when all callers are decompiled
|
||||
addhook(0x006C42D9, (int)scrolling_text_setup, 0, (int[]){EAX, ECX, EBP, END}, 0, EBX); // remove when all callers are decompiled
|
||||
addhook(0x006C2321, (int)gfx_get_string_width, 0, (int[]){ESI, END}, 0, ECX); // remove when all callers are decompiled
|
||||
addhook(0x006C2555, (int)format_string, 0, (int[]){EDI, EAX, ECX, END}, 0, 0); // remove when all callers are decompiled
|
||||
|
||||
if (!rct2_init())
|
||||
return false;
|
||||
|
||||
@@ -63,6 +63,11 @@ extern unsigned int gLastKeyPressed;
|
||||
extern int gTextInputCursorPosition;
|
||||
extern int gTextInputLength;
|
||||
|
||||
extern bool gTextInputCompositionActive;
|
||||
extern utf8 gTextInputComposition[32];
|
||||
extern int gTextInputCompositionStart;
|
||||
extern int gTextInputCompositionLength;
|
||||
|
||||
extern int gResolutionsAllowAnyAspectRatio;
|
||||
extern int gNumResolutions;
|
||||
extern resolution *gResolutions;
|
||||
@@ -114,7 +119,7 @@ unsigned int platform_get_ticks();
|
||||
void platform_get_user_directory(char *outPath, const char *subDirectory);
|
||||
void platform_show_messagebox(char *message);
|
||||
int platform_open_common_file_dialog(int type, char *title, char *filename, char *filterPattern, char *filterName);
|
||||
char *platform_open_directory_browser(char *title);
|
||||
utf8 *platform_open_directory_browser(utf8 *title);
|
||||
uint8 platform_get_locale_currency();
|
||||
uint16 platform_get_locale_language();
|
||||
uint8 platform_get_locale_measurement_format();
|
||||
|
||||
+72
-37
@@ -39,11 +39,16 @@ openrct2_cursor gCursorState;
|
||||
const unsigned char *gKeysState;
|
||||
unsigned char *gKeysPressed;
|
||||
unsigned int gLastKeyPressed;
|
||||
char* gTextInput;
|
||||
utf8 *gTextInput;
|
||||
int gTextInputLength;
|
||||
int gTextInputMaxLength;
|
||||
int gTextInputCursorPosition = 0;
|
||||
|
||||
bool gTextInputCompositionActive;
|
||||
utf8 gTextInputComposition[32];
|
||||
int gTextInputCompositionStart;
|
||||
int gTextInputCompositionLength;
|
||||
|
||||
int gNumResolutions = 0;
|
||||
resolution *gResolutions = NULL;
|
||||
int gResolutionsAllowAnyAspectRatio = 0;
|
||||
@@ -402,6 +407,8 @@ void platform_process_messages()
|
||||
}
|
||||
break;
|
||||
case SDL_KEYDOWN:
|
||||
if (gTextInputCompositionActive) break;
|
||||
|
||||
if (e.key.keysym.sym == SDLK_KP_ENTER){
|
||||
// Map Keypad enter to regular enter.
|
||||
e.key.keysym.scancode = SDL_SCANCODE_RETURN;
|
||||
@@ -420,14 +427,22 @@ void platform_process_messages()
|
||||
// Text input
|
||||
|
||||
// If backspace and we have input text with a cursor position none zero
|
||||
if (e.key.keysym.sym == SDLK_BACKSPACE && gTextInputLength > 0 && gTextInput && gTextInputCursorPosition){
|
||||
if (e.key.keysym.sym == SDLK_BACKSPACE && gTextInputLength > 0 && gTextInput != NULL && gTextInputCursorPosition) {
|
||||
int dstIndex = gTextInputCursorPosition;
|
||||
do {
|
||||
if (dstIndex == 0) break;
|
||||
dstIndex--;
|
||||
} while (!utf8_is_codepoint_start(&gTextInput[dstIndex]));
|
||||
int removedCodepointSize = gTextInputCursorPosition - dstIndex;
|
||||
|
||||
// When at max length don't shift the data left
|
||||
// as it would buffer overflow.
|
||||
if (gTextInputCursorPosition != gTextInputMaxLength)
|
||||
memmove(gTextInput + gTextInputCursorPosition - 1, gTextInput + gTextInputCursorPosition, gTextInputMaxLength - gTextInputCursorPosition - 1);
|
||||
gTextInput[gTextInputLength - 1] = '\0';
|
||||
gTextInputCursorPosition--;
|
||||
gTextInputLength--;
|
||||
if (gTextInputCursorPosition != gTextInputMaxLength) {
|
||||
memmove(gTextInput + dstIndex, gTextInput + gTextInputCursorPosition, gTextInputMaxLength - dstIndex);
|
||||
}
|
||||
gTextInput[gTextInputLength - removedCodepointSize] = '\0';
|
||||
gTextInputCursorPosition -= removedCodepointSize;
|
||||
gTextInputLength -= removedCodepointSize;
|
||||
console_refresh_caret();
|
||||
window_update_textbox();
|
||||
}
|
||||
@@ -435,46 +450,58 @@ void platform_process_messages()
|
||||
gTextInputCursorPosition = gTextInputLength;
|
||||
console_refresh_caret();
|
||||
}
|
||||
if (e.key.keysym.sym == SDLK_HOME){
|
||||
if (e.key.keysym.sym == SDLK_HOME) {
|
||||
gTextInputCursorPosition = 0;
|
||||
console_refresh_caret();
|
||||
}
|
||||
if (e.key.keysym.sym == SDLK_DELETE && gTextInputLength > 0 && gTextInput && gTextInputCursorPosition != gTextInputLength){
|
||||
memmove(gTextInput + gTextInputCursorPosition, gTextInput + gTextInputCursorPosition + 1, gTextInputMaxLength - gTextInputCursorPosition - 1);
|
||||
gTextInput[gTextInputMaxLength - 1] = '\0';
|
||||
gTextInputLength--;
|
||||
if (e.key.keysym.sym == SDLK_DELETE && gTextInputLength > 0 && gTextInput != NULL && gTextInputCursorPosition != gTextInputLength) {
|
||||
int dstIndex = gTextInputCursorPosition;
|
||||
do {
|
||||
if (dstIndex == gTextInputLength) break;
|
||||
dstIndex++;
|
||||
} while (!utf8_is_codepoint_start(&gTextInput[dstIndex]));
|
||||
int removedCodepointSize = dstIndex - gTextInputCursorPosition;
|
||||
|
||||
memmove(gTextInput + gTextInputCursorPosition, gTextInput + dstIndex, gTextInputMaxLength - dstIndex);
|
||||
gTextInput[gTextInputMaxLength - removedCodepointSize] = '\0';
|
||||
gTextInputLength -= removedCodepointSize;
|
||||
console_refresh_caret();
|
||||
window_update_textbox();
|
||||
}
|
||||
if (e.key.keysym.sym == SDLK_RETURN && gTextInput) {
|
||||
if (e.key.keysym.sym == SDLK_RETURN && gTextInput != NULL) {
|
||||
window_cancel_textbox();
|
||||
}
|
||||
if (e.key.keysym.sym == SDLK_LEFT && gTextInput){
|
||||
if (gTextInputCursorPosition) gTextInputCursorPosition--;
|
||||
if (e.key.keysym.sym == SDLK_LEFT && gTextInput != NULL) {
|
||||
do {
|
||||
if (gTextInputCursorPosition == 0) break;
|
||||
gTextInputCursorPosition--;
|
||||
} while (!utf8_is_codepoint_start(&gTextInput[gTextInputCursorPosition]));
|
||||
console_refresh_caret();
|
||||
}
|
||||
else if (e.key.keysym.sym == SDLK_RIGHT && gTextInput){
|
||||
if (gTextInputCursorPosition < gTextInputLength) gTextInputCursorPosition++;
|
||||
else if (e.key.keysym.sym == SDLK_RIGHT && gTextInput != NULL) {
|
||||
do {
|
||||
if (gTextInputCursorPosition == gTextInputLength) break;
|
||||
gTextInputCursorPosition++;
|
||||
} while (!utf8_is_codepoint_start(&gTextInput[gTextInputCursorPosition]));
|
||||
console_refresh_caret();
|
||||
}
|
||||
// Checks GUI modifier key for Macs otherwise ctrl key
|
||||
// Checks GUI modifier key for MACs otherwise CTRL key
|
||||
#ifdef MAC
|
||||
else if (e.key.keysym.sym == SDLK_v && SDL_GetModState() & KMOD_GUI && gTextInput) {
|
||||
else if (e.key.keysym.sym == SDLK_v && SDL_GetModState() & KMOD_GUI && gTextInput != NULL) {
|
||||
#else
|
||||
else if (e.key.keysym.sym == SDLK_v && SDL_GetModState() & KMOD_CTRL && gTextInput) {
|
||||
else if (e.key.keysym.sym == SDLK_v && SDL_GetModState() & KMOD_CTRL && gTextInput != NULL) {
|
||||
#endif
|
||||
if (SDL_HasClipboardText()) {
|
||||
char* text = SDL_GetClipboardText();
|
||||
|
||||
utf8 *text = SDL_GetClipboardText();
|
||||
for (int i = 0; text[i] != '\0' && gTextInputLength < gTextInputMaxLength; i++) {
|
||||
// If inserting in center of string make space for new letter
|
||||
if (gTextInputLength > gTextInputCursorPosition){
|
||||
memmove(gTextInput + gTextInputCursorPosition + 1, gTextInput + gTextInputCursorPosition, gTextInputMaxLength - gTextInputCursorPosition - 1);
|
||||
gTextInput[gTextInputCursorPosition] = text[i];
|
||||
gTextInputLength++;
|
||||
} else {
|
||||
gTextInput[gTextInputLength++] = text[i];
|
||||
}
|
||||
else gTextInput[gTextInputLength++] = text[i];
|
||||
|
||||
gTextInputCursorPosition++;
|
||||
}
|
||||
window_update_textbox();
|
||||
@@ -500,29 +527,33 @@ void platform_process_messages()
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_TEXTEDITING:
|
||||
strcpy(gTextInputComposition, e.edit.text);
|
||||
gTextInputCompositionStart = e.edit.start;
|
||||
gTextInputCompositionLength = e.edit.length;
|
||||
gTextInputCompositionActive = gTextInputComposition[0] != 0;
|
||||
break;
|
||||
case SDL_TEXTINPUT:
|
||||
if (gTextInputLength < gTextInputMaxLength && gTextInput){
|
||||
// Convert the utf-8 code into rct ascii
|
||||
char new_char;
|
||||
// HACK ` will close console, so don't input any text
|
||||
if (e.text.text[0] == '`' && gConsoleOpen)
|
||||
break;
|
||||
if (!(e.text.text[0] & 0x80))
|
||||
new_char = *e.text.text;
|
||||
else if (!(e.text.text[0] & 0x20))
|
||||
new_char = ((e.text.text[0] & 0x1F) << 6) | (e.text.text[1] & 0x3F);
|
||||
|
||||
utf8 *newText = e.text.text;
|
||||
int newTextLength = strlen(newText);
|
||||
|
||||
// If inserting in center of string make space for new letter
|
||||
if (gTextInputLength > gTextInputCursorPosition){
|
||||
memmove(gTextInput + gTextInputCursorPosition + 1, gTextInput + gTextInputCursorPosition, gTextInputMaxLength - gTextInputCursorPosition - 1);
|
||||
gTextInput[gTextInputCursorPosition] = new_char;
|
||||
gTextInputLength++;
|
||||
if (gTextInputLength > gTextInputCursorPosition) {
|
||||
memmove(gTextInput + gTextInputCursorPosition + newTextLength, gTextInput + gTextInputCursorPosition, gTextInputMaxLength - gTextInputCursorPosition - newTextLength);
|
||||
memcpy(&gTextInput[gTextInputCursorPosition], newText, newTextLength);
|
||||
gTextInputLength += newTextLength;
|
||||
} else {
|
||||
gTextInput[gTextInputLength++] = new_char;
|
||||
memcpy(&gTextInput[gTextInputLength], newText, newTextLength);
|
||||
gTextInputLength += newTextLength;
|
||||
gTextInput[gTextInputLength] = 0;
|
||||
}
|
||||
|
||||
gTextInputCursorPosition++;
|
||||
gTextInputCursorPosition += newTextLength;
|
||||
console_refresh_caret();
|
||||
window_update_textbox();
|
||||
}
|
||||
@@ -625,6 +656,10 @@ void platform_free()
|
||||
|
||||
void platform_start_text_input(char* buffer, int max_length)
|
||||
{
|
||||
// TODO This doesn't work, and position could be improved to where text entry is
|
||||
SDL_Rect rect = { 10, 10, 100, 100 };
|
||||
SDL_SetTextInputRect(&rect);
|
||||
|
||||
SDL_StartTextInput();
|
||||
gTextInputMaxLength = max_length - 1;
|
||||
gTextInput = buffer;
|
||||
|
||||
+40
-26
@@ -373,43 +373,52 @@ void platform_show_messagebox(char *message)
|
||||
*
|
||||
* rct2: 0x004080EA
|
||||
*/
|
||||
int platform_open_common_file_dialog(int type, char *title, char *filename, char *filterPattern, char *filterName)
|
||||
int platform_open_common_file_dialog(int type, utf8 *title, utf8 *filename, utf8 *filterPattern, utf8 *filterName)
|
||||
{
|
||||
char initialDirectory[MAX_PATH], *dotAddress, *slashAddress;
|
||||
OPENFILENAME openFileName;
|
||||
wchar_t wctitle[256], wcfilename[MAX_PATH], wcfilterPattern[256], wcfilterName[256];
|
||||
wchar_t initialDirectory[MAX_PATH], *dotAddress, *slashAddress;
|
||||
OPENFILENAMEW openFileName;
|
||||
BOOL result;
|
||||
int tmp;
|
||||
DWORD commonFlags;
|
||||
|
||||
MultiByteToWideChar(CP_UTF8, 0, title, -1, wctitle, countof(wctitle));
|
||||
MultiByteToWideChar(CP_UTF8, 0, filename, -1, wcfilename, countof(wcfilename));
|
||||
MultiByteToWideChar(CP_UTF8, 0, filterPattern, -1, wcfilterPattern, countof(wcfilterPattern));
|
||||
MultiByteToWideChar(CP_UTF8, 0, filterName, -1, wcfilterName, countof(wcfilterName));
|
||||
|
||||
// Get directory path from given filename
|
||||
strcpy(initialDirectory, filename);
|
||||
dotAddress = strrchr(initialDirectory, '.');
|
||||
lstrcpyW(initialDirectory, wcfilename);
|
||||
dotAddress = wcsrchr(initialDirectory, '.');
|
||||
if (dotAddress != NULL) {
|
||||
slashAddress = strrchr(initialDirectory, '\\');
|
||||
slashAddress = wcsrchr(initialDirectory, '\\');
|
||||
if (slashAddress < dotAddress)
|
||||
*(slashAddress + 1) = 0;
|
||||
}
|
||||
|
||||
// Clear filename
|
||||
if (type != 0)
|
||||
*filename = 0;
|
||||
wcfilename[0] = 0;
|
||||
|
||||
// Set open file name options
|
||||
memset(&openFileName, 0, sizeof(OPENFILENAME));
|
||||
openFileName.lStructSize = sizeof(OPENFILENAME);
|
||||
memset(&openFileName, 0, sizeof(OPENFILENAMEW));
|
||||
openFileName.lStructSize = sizeof(OPENFILENAMEW);
|
||||
openFileName.hwndOwner = windows_get_window_handle();
|
||||
openFileName.lpstrFile = filename;
|
||||
openFileName.lpstrFile = wcfilename;
|
||||
openFileName.nMaxFile = MAX_PATH;
|
||||
openFileName.lpstrInitialDir = initialDirectory;
|
||||
openFileName.lpstrTitle = title;
|
||||
openFileName.lpstrTitle = wctitle;
|
||||
|
||||
// Copy filter name
|
||||
strcpy((char*)0x01423800, filterName);
|
||||
lstrcpyW((wchar_t*)0x01423800, wcfilterName);
|
||||
|
||||
// Copy filter pattern
|
||||
strcpy((char*)0x01423800 + strlen(filterName) + 1, filterPattern);
|
||||
*((char*)(0x01423800 + strlen(filterName) + 1 + strlen(filterPattern) + 1)) = 0;
|
||||
openFileName.lpstrFilter = (char*)0x01423800;
|
||||
int wcfilterNameLength = lstrlenW(wcfilterName);
|
||||
int wcfilterPatternLength = lstrlenW(wcfilterPattern);
|
||||
|
||||
lstrcpyW((wchar_t*)0x01423800 + wcfilterNameLength + 1, wcfilterPattern);
|
||||
*((wchar_t*)((wchar_t*)0x01423800 + wcfilterNameLength + 1 + wcfilterPatternLength + 1)) = 0;
|
||||
openFileName.lpstrFilter = (wchar_t*)0x01423800;
|
||||
|
||||
//
|
||||
tmp = RCT2_GLOBAL(0x009E2C74, uint32);
|
||||
@@ -420,25 +429,29 @@ int platform_open_common_file_dialog(int type, char *title, char *filename, char
|
||||
commonFlags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
|
||||
if (type == 0) {
|
||||
openFileName.Flags = commonFlags | OFN_CREATEPROMPT | OFN_OVERWRITEPROMPT;
|
||||
result = GetSaveFileName(&openFileName);
|
||||
result = GetSaveFileNameW(&openFileName);
|
||||
} else if (type == 1) {
|
||||
openFileName.Flags = commonFlags | OFN_NONETWORKBUTTON | OFN_FILEMUSTEXIST;
|
||||
result = GetOpenFileName(&openFileName);
|
||||
result = GetOpenFileNameW(&openFileName);
|
||||
}
|
||||
|
||||
//
|
||||
RCT2_GLOBAL(0x009E2C74, uint32) = tmp;
|
||||
|
||||
WideCharToMultiByte(CP_UTF8, 0, wcfilename, countof(wcfilename), filename, MAX_PATH, NULL, NULL);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
char *platform_open_directory_browser(char *title)
|
||||
utf8 *platform_open_directory_browser(utf8 *title)
|
||||
{
|
||||
BROWSEINFO bi;
|
||||
char pszBuffer[MAX_PATH];
|
||||
BROWSEINFOW bi;
|
||||
wchar_t pszBuffer[MAX_PATH], wctitle[256];
|
||||
LPITEMIDLIST pidl;
|
||||
LPMALLOC lpMalloc;
|
||||
|
||||
MultiByteToWideChar(CP_UTF8, 0, title, -1, wctitle, countof(wctitle));
|
||||
|
||||
// Initialize COM
|
||||
if (FAILED(CoInitializeEx(0, COINIT_APARTMENTTHREADED))) {
|
||||
CoUninitialize();
|
||||
@@ -458,19 +471,20 @@ char *platform_open_directory_browser(char *title)
|
||||
bi.hwndOwner = NULL;
|
||||
bi.pidlRoot = NULL;
|
||||
bi.pszDisplayName = pszBuffer;
|
||||
bi.lpszTitle = title;
|
||||
bi.lpszTitle = wctitle;
|
||||
bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
|
||||
bi.lpfn = NULL;
|
||||
bi.lParam = 0;
|
||||
|
||||
char *outPath = NULL;
|
||||
utf8 *outPath = NULL;
|
||||
|
||||
if (pidl = SHBrowseForFolder(&bi)) {
|
||||
if (pidl = SHBrowseForFolderW(&bi)) {
|
||||
// Copy the path directory to the buffer
|
||||
if (SHGetPathFromIDList(pidl, pszBuffer)) {
|
||||
if (SHGetPathFromIDListW(pidl, pszBuffer)) {
|
||||
// Store pszBuffer (and the path) in the outPath
|
||||
outPath = (char*) malloc(strlen(pszBuffer)+1);
|
||||
strcpy(outPath, pszBuffer);
|
||||
int outPathCapacity = lstrlenW(pszBuffer) * 4 + 1;
|
||||
outPath = (utf8*)malloc(outPathCapacity);
|
||||
WideCharToMultiByte(CP_UTF8, 0, pszBuffer, countof(pszBuffer), outPath, outPathCapacity, NULL, NULL);
|
||||
}
|
||||
}
|
||||
CoUninitialize();
|
||||
|
||||
+5
-1
@@ -51,6 +51,8 @@
|
||||
#include "world/scenery.h"
|
||||
#include "world/sprite.h"
|
||||
|
||||
uint32 gCurrentDrawCount = 0;
|
||||
|
||||
typedef struct tm tm_t;
|
||||
|
||||
void print_launch_information();
|
||||
@@ -97,7 +99,7 @@ int rct2_init()
|
||||
|
||||
gfx_load_g1();
|
||||
gfx_load_g2();
|
||||
gfx_load_character_widths();
|
||||
font_sprite_initialise_characters();
|
||||
if (!gOpenRCT2Headless) {
|
||||
platform_init();
|
||||
audio_init1();
|
||||
@@ -236,6 +238,8 @@ void rct2_draw()
|
||||
} else {
|
||||
//game
|
||||
}
|
||||
|
||||
gCurrentDrawCount++;
|
||||
}
|
||||
|
||||
int rct2_open_file(const char *path)
|
||||
|
||||
@@ -286,6 +286,8 @@ static const struct file_to_check
|
||||
{ PATH_ID_END, 0 }
|
||||
};
|
||||
|
||||
extern uint32 gCurrentDrawCount;
|
||||
|
||||
int rct2_init();
|
||||
void rct2_update();
|
||||
void rct2_draw();
|
||||
|
||||
+14
-10
@@ -3111,20 +3111,24 @@ rct_track_design *temp_track_get_info(char* path, uint8** preview)
|
||||
return trackDesign;
|
||||
}
|
||||
|
||||
void window_track_list_format_name(char *dst, const char *src, char colour, char quotes)
|
||||
void window_track_list_format_name(utf8 *dst, const utf8 *src, int colour, bool quotes)
|
||||
{
|
||||
if (colour != 0)
|
||||
*dst++ = colour;
|
||||
const utf8 *ch;
|
||||
int codepoint;
|
||||
|
||||
if (quotes != 0)
|
||||
*dst++ = FORMAT_OPENQUOTES;
|
||||
|
||||
while (*src != '.' && *src != 0) {
|
||||
*dst++ = *src++;
|
||||
if (colour != 0) {
|
||||
dst = utf8_write_codepoint(dst, colour);
|
||||
}
|
||||
|
||||
if (quotes != 0)
|
||||
*dst++ = FORMAT_ENDQUOTES;
|
||||
if (quotes) dst = utf8_write_codepoint(dst, FORMAT_OPENQUOTES);
|
||||
|
||||
ch = src;
|
||||
while ((codepoint = utf8_get_next(ch, &ch)) != 0) {
|
||||
if (codepoint == '.') break;
|
||||
dst = utf8_write_codepoint(dst, codepoint);
|
||||
}
|
||||
|
||||
if (quotes) dst = utf8_write_codepoint(dst, FORMAT_ENDQUOTES);
|
||||
|
||||
*dst = 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -512,7 +512,7 @@ int track_is_connected_by_shape(rct_map_element *a, rct_map_element *b);
|
||||
int sub_6D01B3(uint8 bl, uint8 rideIndex, int x, int y, int z);
|
||||
int save_track_design(uint8 rideIndex);
|
||||
int install_track(char* source_path, char* dest_name);
|
||||
void window_track_list_format_name(char *dst, const char *src, char colour, char quotes);
|
||||
void window_track_list_format_name(utf8 *dst, const utf8 *src, int colour, bool quotes);
|
||||
void game_command_place_track_design(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp);
|
||||
|
||||
void track_save_reset_scenery();
|
||||
|
||||
@@ -180,6 +180,7 @@ int scenario_load(const char *path)
|
||||
map_update_tile_pointers();
|
||||
reset_0x69EBE4();
|
||||
openrct2_reset_object_tween_locations();
|
||||
game_convert_strings_to_utf8();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -965,6 +966,7 @@ int scenario_save(SDL_RWops* rw, int flags)
|
||||
memcpy(&s6->dword_010E63B8, (void*)0x010E63B8, 0x2E8570);
|
||||
|
||||
scenario_fix_ghosts(s6);
|
||||
game_convert_strings_to_rct2(s6);
|
||||
scenario_save_s6(rw, s6);
|
||||
|
||||
free(s6);
|
||||
|
||||
+9
-1
@@ -436,7 +436,15 @@ void DrawOpenRCT2(int x, int y)
|
||||
gfx_fill_rect_inset(dpi, x, y, x + 128, y + 20, 0x80 | 12, 0x8);
|
||||
|
||||
// Format text (name and version)
|
||||
sprintf(buffer, "%c%c%c%s, v%s", FORMAT_MEDIUMFONT, FORMAT_OUTLINE, FORMAT_WHITE, OPENRCT2_NAME, OPENRCT2_VERSION);
|
||||
char *ch = buffer;;
|
||||
ch = utf8_write_codepoint(ch, FORMAT_MEDIUMFONT);
|
||||
ch = utf8_write_codepoint(ch, FORMAT_OUTLINE);
|
||||
ch = utf8_write_codepoint(ch, FORMAT_WHITE);
|
||||
strcpy(ch, OPENRCT2_NAME);
|
||||
strcat(buffer, ", v");
|
||||
strcat(buffer, OPENRCT2_VERSION);
|
||||
|
||||
// sprintf(buffer, "%c%c%c%s, v%s", FORMAT_MEDIUMFONT, FORMAT_OUTLINE, FORMAT_WHITE, OPENRCT2_NAME, OPENRCT2_VERSION);
|
||||
if (!str_is_null_or_empty(OPENRCT2_BRANCH))
|
||||
sprintf(strchr(buffer, 0), "-%s", OPENRCT2_BRANCH);
|
||||
if (!str_is_null_or_empty(OPENRCT2_BUILD_NUMBER))
|
||||
|
||||
+15
-18
@@ -263,21 +263,18 @@ static void window_banner_dropdown(rct_window *w, int widgetIndex, int dropdownI
|
||||
|
||||
banner->text_colour = dropdownIndex + 1;
|
||||
|
||||
// Can be replaced with a buffer 34 chars wide ( 32 character + 1 colour_format + 1 '\0')
|
||||
uint8* text_buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, uint8);
|
||||
|
||||
format_string(text_buffer, banner->string_idx, 0);
|
||||
|
||||
if (text_buffer[0] < FORMAT_COLOUR_CODE_START
|
||||
|| text_buffer[0] > FORMAT_COLOUR_CODE_END){
|
||||
int end_point = strlen(text_buffer) + 1;
|
||||
strncpy(text_buffer + 1, text_buffer, 32);
|
||||
text_buffer[end_point] = '\0';
|
||||
int colourCodepoint = FORMAT_COLOUR_CODE_START + banner->text_colour;
|
||||
|
||||
uint8 buffer[256];
|
||||
format_string(buffer, banner->string_idx, 0);
|
||||
int firstCodepoint = utf8_get_next(buffer, NULL);
|
||||
if (firstCodepoint >= FORMAT_COLOUR_CODE_START && firstCodepoint <= FORMAT_COLOUR_CODE_END) {
|
||||
utf8_write_codepoint(buffer, colourCodepoint);
|
||||
} else {
|
||||
utf8_insert_codepoint(buffer, colourCodepoint);
|
||||
}
|
||||
|
||||
text_buffer[0] = banner->text_colour + FORMAT_COLOUR_CODE_START;
|
||||
|
||||
rct_string_id stringId = user_string_allocate(128, text_buffer);
|
||||
rct_string_id stringId = user_string_allocate(128, buffer);
|
||||
if (stringId != 0) {
|
||||
rct_string_id prev_string_id = banner->string_idx;
|
||||
banner->string_idx = stringId;
|
||||
@@ -296,12 +293,12 @@ static void window_banner_textinput(rct_window *w, int widgetIndex, char *text)
|
||||
if (widgetIndex == WIDX_BANNER_TEXT && text != NULL) {
|
||||
rct_banner* banner = &gBanners[w->number];
|
||||
|
||||
uint8* text_buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, uint8);
|
||||
utf8 *buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, uint8);
|
||||
utf8 *dst = buffer;
|
||||
dst = utf8_write_codepoint(dst, FORMAT_COLOUR_CODE_START + banner->text_colour);
|
||||
strncpy(dst, text, 32);
|
||||
|
||||
text_buffer[0] = banner->text_colour + FORMAT_COLOUR_CODE_START;
|
||||
strncpy(text_buffer + 1, text, 32);
|
||||
|
||||
rct_string_id stringId = user_string_allocate(128, text_buffer);
|
||||
rct_string_id stringId = user_string_allocate(128, buffer);
|
||||
if (stringId) {
|
||||
rct_string_id prev_string_id = banner->string_idx;
|
||||
banner->string_idx = stringId;
|
||||
|
||||
@@ -804,7 +804,7 @@ static void window_editor_inventions_list_scrollpaint(rct_window *w, rct_drawpix
|
||||
int left, top, bottom, itemY, disableItemMovement;
|
||||
sint32 researchItemEndMarker;
|
||||
rct_string_id stringId;
|
||||
char buffer[256], *ptr;
|
||||
utf8 buffer[256], *ptr;
|
||||
|
||||
// Draw background
|
||||
colour = RCT2_GLOBAL(0x0141FC48 + (w->colours[1] * 8), uint8);
|
||||
@@ -856,8 +856,9 @@ static void window_editor_inventions_list_scrollpaint(rct_window *w, rct_drawpix
|
||||
stringId = research_item_get_name(researchItem->entryIndex & 0xFFFFFF);
|
||||
|
||||
ptr = buffer;
|
||||
if (!disableItemMovement)
|
||||
*ptr++ = colour & 0xFF;
|
||||
if (!disableItemMovement) {
|
||||
ptr = utf8_write_codepoint(ptr, colour & 0xFF);
|
||||
}
|
||||
|
||||
format_string(ptr, stringId, NULL);
|
||||
|
||||
|
||||
@@ -1439,14 +1439,13 @@ static void window_editor_object_selection_scrollpaint(rct_window *w, rct_drawpi
|
||||
if (*listItem->flags & (OBJECT_SELECTION_FLAG_IN_USE | OBJECT_SELECTION_FLAG_REQUIRED | OBJECT_SELECTION_FLAG_ALWAYS_REQUIRED))
|
||||
colour2 |= 0x40;
|
||||
|
||||
gfx_draw_string(dpi, (char*)0x009DED72, colour2, x, y);
|
||||
gfx_draw_string(dpi, (char*)CheckBoxMarkString, colour2, x, y);
|
||||
}
|
||||
|
||||
x = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER ? 0 : 15;
|
||||
|
||||
char *bufferWithColour = (char*)0x0141ED68;
|
||||
char *buffer = bufferWithColour + 1;
|
||||
bufferWithColour[0] = colour;
|
||||
char *buffer = utf8_write_codepoint(bufferWithColour, colour);
|
||||
if (*listItem->flags & OBJECT_SELECTION_FLAG_6) {
|
||||
colour = w->colours[1] & 0x7F;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, sint16) = -1;
|
||||
|
||||
@@ -1200,7 +1200,7 @@ static void window_editor_objective_options_rides_scrollpaint(rct_window *w, rct
|
||||
ride = GET_RIDE(i);
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE) {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = stringId == 1193 ? 0xFFFE : 0xFFFF;
|
||||
gfx_draw_string(dpi, (char*)0x009DED72, w->colours[1] & 0x7F, 2, y);
|
||||
gfx_draw_string(dpi, (char*)CheckBoxMarkString, w->colours[1] & 0x7F, 2, y);
|
||||
}
|
||||
|
||||
// Ride name
|
||||
|
||||
+6
-5
@@ -80,7 +80,8 @@ static uint16 _window_error_num_lines;
|
||||
*/
|
||||
void window_error_open(rct_string_id title, rct_string_id message)
|
||||
{
|
||||
char *dst, *args;
|
||||
utf8 *dst;
|
||||
char *args;
|
||||
int numLines, fontHeight, x, y, width, height, maxY;
|
||||
rct_window *w;
|
||||
|
||||
@@ -89,17 +90,17 @@ void window_error_open(rct_string_id title, rct_string_id message)
|
||||
args = (char*)0x0013CE952;
|
||||
|
||||
// Format the title
|
||||
*dst++ = FORMAT_BLACK;
|
||||
dst = utf8_write_codepoint(dst, FORMAT_BLACK);
|
||||
if (title != (rct_string_id)STR_NONE) {
|
||||
format_string(dst, title, args);
|
||||
dst += get_string_length(dst);
|
||||
dst = get_string_end(dst);
|
||||
}
|
||||
|
||||
// Format the message
|
||||
if (message != (rct_string_id)STR_NONE) {
|
||||
*dst++ = FORMAT_NEWLINE;
|
||||
dst = utf8_write_codepoint(dst, FORMAT_NEWLINE);
|
||||
format_string(dst, message, args);
|
||||
dst += get_string_length(dst);
|
||||
dst = get_string_end(dst);
|
||||
}
|
||||
|
||||
log_verbose("show error, %s", _window_error_text + 1);
|
||||
|
||||
@@ -523,13 +523,12 @@ static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo *dpi, rc
|
||||
);
|
||||
|
||||
// Text
|
||||
stringId = 1926;
|
||||
// memcpy((char*)language_get_string(1926) + 1, &newsItem->colour, 256);
|
||||
memcpy((void*)0x009B5F2C, &newsItem->colour, 256);
|
||||
stringId = 5485;
|
||||
utf8 *newsItemText = newsItem->text;
|
||||
x = w->x + (middleOutsetWidget->left + middleOutsetWidget->right) / 2;
|
||||
y = w->y + middleOutsetWidget->top + 11;
|
||||
width = middleOutsetWidget->right - middleOutsetWidget->left - 62;
|
||||
sub_6C1F57(dpi, x, y, width, 14, stringId, NULL, newsItem->ticks);
|
||||
gfx_draw_string_centred_wrapped_partial(dpi, x, y, width, 14, stringId, &newsItemText, newsItem->ticks);
|
||||
|
||||
x = w->x + window_game_bottom_toolbar_widgets[WIDX_NEWS_SUBJECT].left;
|
||||
y = w->y + window_game_bottom_toolbar_widgets[WIDX_NEWS_SUBJECT].top;
|
||||
|
||||
+1
-5
@@ -375,11 +375,7 @@ static void window_land_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
|
||||
// FEATURE larger land tool size support
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) > 7) {
|
||||
RCT2_GLOBAL(0x009BC677, char) = FORMAT_BLACK;
|
||||
RCT2_GLOBAL(0x009BC678, char) = FORMAT_COMMA16;
|
||||
RCT2_GLOBAL(0x009BC679, char) = 0;
|
||||
RCT2_GLOBAL(0x013CE952, sint16) = RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16);
|
||||
gfx_draw_string_centred(dpi, 3165, x, y - 2, 0, (void*)0x013CE952);
|
||||
gfx_draw_string_centred(dpi, STR_LAND_TOOL_SIZE_VALUE, x, y - 2, 0, &RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16));
|
||||
}
|
||||
|
||||
x = w->x + (window_land_widgets[WIDX_PREVIEW].left + window_land_widgets[WIDX_PREVIEW].right) / 2 + 17;
|
||||
|
||||
@@ -237,11 +237,7 @@ static void window_land_rights_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
window_draw_widgets(w, dpi);
|
||||
// FEATURE larger land tool size support
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) > 7) {
|
||||
RCT2_GLOBAL(0x009BC677, char) = FORMAT_BLACK;
|
||||
RCT2_GLOBAL(0x009BC678, char) = FORMAT_COMMA16;
|
||||
RCT2_GLOBAL(0x009BC679, char) = 0;
|
||||
RCT2_GLOBAL(0x013CE952, sint16) = RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16);
|
||||
gfx_draw_string_centred(dpi, 3165, x, y - 2, 0, (void*)0x013CE952);
|
||||
gfx_draw_string_centred(dpi, STR_LAND_TOOL_SIZE_VALUE, x, y - 2, 0, &RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16));
|
||||
}
|
||||
y = w->y + window_land_rights_widgets[WIDX_PREVIEW].bottom + 5;
|
||||
|
||||
|
||||
@@ -462,9 +462,14 @@ static void window_loadsave_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
if (_shortenedDirectory[0] == '\0')
|
||||
shorten_path(_directory, _shortenedDirectory, w->width - 8);
|
||||
|
||||
char buffer[256];
|
||||
utf8 buffer[256];
|
||||
|
||||
// Format text
|
||||
sprintf(buffer, "%c%c%s", FORMAT_MEDIUMFONT, FORMAT_BLACK, _shortenedDirectory);
|
||||
utf8 *ch = buffer;
|
||||
ch = utf8_write_codepoint(ch, FORMAT_MEDIUMFONT);
|
||||
ch = utf8_write_codepoint(ch, FORMAT_BLACK);
|
||||
strcpy(ch, _shortenedDirectory);
|
||||
|
||||
// Draw shadow
|
||||
gfx_draw_string(dpi, buffer, 0, w->x + 4, w->y + 20);
|
||||
rct_string_id id = STR_NONE;
|
||||
|
||||
+1
-5
@@ -798,11 +798,7 @@ static void window_map_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
|
||||
// Draw land tool size
|
||||
if (widget_is_active_tool(w, WIDX_SET_LAND_RIGHTS) && RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) > 7) {
|
||||
RCT2_GLOBAL(0x009BC677, char) = FORMAT_BLACK;
|
||||
RCT2_GLOBAL(0x009BC678, char) = FORMAT_COMMA16;
|
||||
RCT2_GLOBAL(0x009BC679, char) = 0;
|
||||
RCT2_GLOBAL(0x013CE952, sint16) = RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16);
|
||||
gfx_draw_string_centred(dpi, 3165, x, y - 2, 0, (void*)0x013CE952);
|
||||
gfx_draw_string_centred(dpi, STR_LAND_TOOL_SIZE_VALUE, x, y - 2, 0, &RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16));
|
||||
}
|
||||
y = w->y + window_map_widgets[WIDX_LAND_TOOL].bottom + 5;
|
||||
|
||||
|
||||
@@ -151,5 +151,5 @@ static void window_map_tooltip_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_TOOLTIP_ARGS, rct_string_id) == (rct_string_id)STR_NONE)
|
||||
return;
|
||||
|
||||
gfx_draw_string_centred_wrapped(dpi, (void*)0x009A9808, w->x + (w->width / 2), w->y + (w->height / 2), w->width, 1162, 0);
|
||||
gfx_draw_string_centred_wrapped(dpi, (void*)RCT2_ADDRESS_MAP_TOOLTIP_ARGS, w->x + (w->width / 2), w->y + (w->height / 2), w->width, 1162, 0);
|
||||
}
|
||||
+6
-5
@@ -295,11 +295,12 @@ static void window_news_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int s
|
||||
gfx_draw_string_left(dpi, 2235, (void*)0x013CE952, 2, 4, y);
|
||||
|
||||
// Item text
|
||||
char sz[400];// = (char*)0x09B5F2C;
|
||||
char* args[1];
|
||||
args[0] = (char*)&sz;
|
||||
sprintf(sz, "%c%c%s", newsItem->colour, FORMAT_SMALLFONT, newsItem->text);
|
||||
gfx_draw_string_left_wrapped(dpi, args, 2, y + 10, 325, 1170, 14);
|
||||
utf8 buffer[400];
|
||||
utf8 *ch = buffer;
|
||||
ch = utf8_write_codepoint(ch, FORMAT_SMALLFONT);
|
||||
memcpy(ch, newsItem->text, 256);
|
||||
ch = buffer;
|
||||
gfx_draw_string_left_wrapped(dpi, &ch, 2, y + 10, 325, 1170, 14);
|
||||
|
||||
// Subject button
|
||||
if ((RCT2_ADDRESS(0x0097BE7C, uint8)[newsItem->type] & 2) && !(newsItem->flags & 1)) {
|
||||
|
||||
@@ -759,7 +759,7 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget*
|
||||
case WIDX_LANGUAGE_DROPDOWN:
|
||||
for (i = 1; i < LANGUAGE_COUNT; i++) {
|
||||
gDropdownItemsFormat[i - 1] = 2777;
|
||||
gDropdownItemsArgs[i - 1] = (sint32)language_names[i];
|
||||
gDropdownItemsArgs[i - 1] = (sint32)LanguagesDescriptors[i].native_name;
|
||||
}
|
||||
window_options_show_dropdown(w, widget, LANGUAGE_COUNT - 1);
|
||||
gDropdownItemsChecked = 1 << (gCurrentLanguage - 1);
|
||||
@@ -1289,7 +1289,7 @@ static void window_options_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224;
|
||||
gfx_draw_string(
|
||||
dpi,
|
||||
(char*)language_names[gCurrentLanguage],
|
||||
(char*)LanguagesDescriptors[gCurrentLanguage].native_name,
|
||||
w->colours[1],
|
||||
w->x + window_options_culture_widgets[WIDX_LANGUAGE].left + 1,
|
||||
w->y + window_options_culture_widgets[WIDX_LANGUAGE].top
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "../interface/window.h"
|
||||
#include "../interface/widget.h"
|
||||
#include "../localisation/localisation.h"
|
||||
#include "../util/util.h"
|
||||
|
||||
#define WW 250
|
||||
#define WH 90
|
||||
@@ -117,6 +118,8 @@ void window_text_input_open(rct_window* call_w, int call_widget, rct_string_id t
|
||||
// from crashing the game.
|
||||
text_input[maxLength - 1] = '\0';
|
||||
|
||||
utf8_remove_format_codes(text_input);
|
||||
|
||||
// This is the text displayed above the input box
|
||||
input_text_description = description;
|
||||
|
||||
@@ -284,16 +287,18 @@ static void window_text_input_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
int char_count = 0;
|
||||
uint8 cur_drawn = 0;
|
||||
|
||||
for (int line = 0; line <= no_lines; ++line){
|
||||
int cursorX, cursorY;
|
||||
for (int line = 0; line <= no_lines; line++) {
|
||||
gfx_draw_string(dpi, wrap_pointer, w->colours[1], w->x + 12, y);
|
||||
|
||||
int string_length = get_string_length(wrap_pointer);
|
||||
int string_length = get_string_size(wrap_pointer) - 1;
|
||||
|
||||
if (!cur_drawn && (gTextInputCursorPosition <= char_count + string_length)){
|
||||
if (!cur_drawn && (gTextInputCursorPosition <= char_count + string_length)) {
|
||||
// Make a copy of the string for measuring the width.
|
||||
char temp_string[512] = { 0 };
|
||||
memcpy(temp_string, wrap_pointer, gTextInputCursorPosition - char_count);
|
||||
int cur_x = w->x + 13 + gfx_get_string_width(temp_string);
|
||||
cursorX = w->x + 13 + gfx_get_string_width(temp_string);
|
||||
cursorY = y;
|
||||
|
||||
int width = 6;
|
||||
if ((uint32)gTextInputCursorPosition < strlen(text_input)){
|
||||
@@ -306,7 +311,7 @@ static void window_text_input_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
|
||||
if (w->frame_no > 15){
|
||||
uint8 colour = RCT2_ADDRESS(0x0141FC48, uint8)[w->colours[1] * 8];
|
||||
gfx_fill_rect(dpi, cur_x, y + 9, cur_x + width, y + 9, colour + 5);
|
||||
gfx_fill_rect(dpi, cursorX, y + 9, cursorX + width, y + 9, colour + 5);
|
||||
}
|
||||
|
||||
cur_drawn++;
|
||||
@@ -319,6 +324,24 @@ static void window_text_input_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
|
||||
y += 10;
|
||||
}
|
||||
|
||||
if (!cur_drawn) {
|
||||
cursorX = gLastDrawStringX;
|
||||
cursorY = y - 10;
|
||||
}
|
||||
|
||||
// IME composition
|
||||
if (gTextInputCompositionActive) {
|
||||
int compositionWidth = gfx_get_string_width(gTextInputComposition);
|
||||
int x = cursorX - (compositionWidth / 2);
|
||||
int y = cursorY + 13;
|
||||
int w = compositionWidth;
|
||||
int h = 10;
|
||||
|
||||
gfx_fill_rect(dpi, x - 1, y - 1, x + w + 1, y + h + 1, 12);
|
||||
gfx_fill_rect(dpi, x, y, x + w, y + h, 0);
|
||||
gfx_draw_string(dpi, gTextInputComposition, 12, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
void window_text_input_key(rct_window* w, int key)
|
||||
|
||||
@@ -881,7 +881,7 @@ void window_themes_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scroll
|
||||
gfx_fill_rect_inset(dpi, _button_offset_x + 12 * j, y + _check_offset_y, _button_offset_x + 12 * j + 9, y + _check_offset_y + 10, w->colours[1], 0xE0);
|
||||
if (get_colour_scheme_tab_by_index(i)->colours[j] & 0x80) {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, sint16) = -1;
|
||||
gfx_draw_string(dpi, (char*)0x009DED72, w->colours[1] & 0x7F, _button_offset_x + 12 * j, y + _check_offset_y);
|
||||
gfx_draw_string(dpi, (char*)CheckBoxMarkString, w->colours[1] & 0x7F, _button_offset_x + 12 * j, y + _check_offset_y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+8
-11
@@ -112,24 +112,21 @@ void window_tooltip_open(rct_window *widgetWindow, int widgetIndex, int x, int y
|
||||
char* buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, char);
|
||||
|
||||
format_string(buffer, widget->tooltip, (void*)0x013CE952);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224;
|
||||
|
||||
int tooltip_text_width = 0, tooltip_text_height = 0;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = FONT_SPRITE_BASE_MEDIUM;
|
||||
|
||||
int tooltip_text_width;
|
||||
tooltip_text_width = gfx_get_string_width_new_lined(buffer);
|
||||
buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, char);
|
||||
tooltip_text_width &= 0xFFFF;
|
||||
if (tooltip_text_width > 196)
|
||||
tooltip_text_width = 196;
|
||||
tooltip_text_width = min(tooltip_text_width, 196);
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = FONT_SPRITE_BASE_MEDIUM;
|
||||
|
||||
int fontHeight;
|
||||
tooltip_text_width = gfx_wrap_string(buffer, tooltip_text_width + 1, &tooltip_text_height, &fontHeight);
|
||||
int numLines, fontSpriteBase;
|
||||
tooltip_text_width = gfx_wrap_string(buffer, tooltip_text_width + 1, &numLines, &fontSpriteBase);
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TEXT_HEIGHT, sint16) = tooltip_text_height;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TEXT_HEIGHT, sint16) = numLines;
|
||||
width = tooltip_text_width + 3;
|
||||
height = ((tooltip_text_height + 1) * 10) + 4;
|
||||
height = ((numLines + 1) * font_get_line_height(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16))) + 4;
|
||||
window_tooltip_widgets[WIDX_BACKGROUND].right = width;
|
||||
window_tooltip_widgets[WIDX_BACKGROUND].bottom = height;
|
||||
|
||||
|
||||
+1
-5
@@ -240,11 +240,7 @@ static void window_water_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
window_draw_widgets(w, dpi);
|
||||
// FEATURE larger land tool size support
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) > 7) {
|
||||
RCT2_GLOBAL(0x009BC677, char) = FORMAT_BLACK;
|
||||
RCT2_GLOBAL(0x009BC678, char) = FORMAT_COMMA16;
|
||||
RCT2_GLOBAL(0x009BC679, char) = 0;
|
||||
RCT2_GLOBAL(0x013CE952, sint16) = RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16);
|
||||
gfx_draw_string_centred(dpi, 3165, x, y - 2, 0, (void*)0x013CE952);
|
||||
gfx_draw_string_centred(dpi, STR_LAND_TOOL_SIZE_VALUE, x, y - 2, 0, &RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16));
|
||||
}
|
||||
y = w->y + window_water_widgets[WIDX_PREVIEW].bottom + 5;
|
||||
|
||||
|
||||
Reference in new issue
Block a user