mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge branch 'twitch-integration' into develop
This commit is contained in:
commit
a85bdf2ba8
|
@ -11,6 +11,11 @@ distribution/windows/*.exe
|
|||
# Build artifacts
|
||||
.cache
|
||||
|
||||
#libcurl
|
||||
lib/libcurl/
|
||||
#libjansson
|
||||
lib/jansson/
|
||||
|
||||
#################
|
||||
## Eclipse
|
||||
#################
|
||||
|
|
|
@ -25,6 +25,14 @@ project(${PROJECT})
|
|||
|
||||
add_definitions(-DORCT2_RESOURCE_DIR="${ORCT2_RESOURCE_DIR}")
|
||||
add_definitions(-DHAVE_CONFIG_H)
|
||||
add_definitions(-DCURL_STATICLIB)
|
||||
#uncomment the line bellow if you don't want to build openrct2 with twitch integration
|
||||
#add_definitions(-DDISABLE_HTTP -DDISABLE_TWITCH)
|
||||
|
||||
set(ORCALIBS_INCLUDE /usr/local/cross-tools/orcalibs/include)
|
||||
set(JANSSON_INCLUDE /usr/local/cross-tools/orcalibs/include/jansson)
|
||||
set(ORCALIBS_LIB_DIR /usr/local/cross-tools/orcalibs/lib)
|
||||
set(ORCALIBS_LIB jansson curl ssl crypto ws2_32)
|
||||
|
||||
# include lib
|
||||
include_directories("lib/")
|
||||
|
@ -44,7 +52,8 @@ if (UNIX)
|
|||
INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS})
|
||||
endif (UNIX)
|
||||
|
||||
LINK_DIRECTORIES(${SDL2_LIBRARY_DIRS})
|
||||
INCLUDE_DIRECTORIES(${ORCALIBS_INCLUDE} ${JANSSON_INCLUDE})
|
||||
LINK_DIRECTORIES(${SDL2_LIBRARY_DIRS} ${ORCALIBS_LIB_DIR})
|
||||
|
||||
# build as library for now, replace with add_executable
|
||||
add_library(${PROJECT} SHARED ${ORCT2_SOURCES})
|
||||
|
@ -55,7 +64,7 @@ add_library(${PROJECT} SHARED ${ORCT2_SOURCES})
|
|||
# libopenrct2.dll -> openrct2.dll
|
||||
set_target_properties(${PROJECT} PROPERTIES PREFIX "")
|
||||
|
||||
TARGET_LINK_LIBRARIES(${PROJECT} ${SDL2_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES(${PROJECT} ${SDL2_LIBRARIES} ${ORCALIBS_LIB})
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(${PROJECT} winmm.lib -limm32 -lversion -ldsound)
|
||||
|
|
|
@ -10,7 +10,8 @@ SET(PKG_CONFIG_EXECUTABLE ${COMPILER_PREFIX}-pkg-config)
|
|||
# potential flags to make code more similar to MSVC:
|
||||
# -fshort-wchar -fshort-enums -mms-bitfields
|
||||
#
|
||||
set(CMAKE_C_FLAGS "-masm=intel -std=gnu99 -fpack-struct=2" CACHE STRING "" FORCE)
|
||||
set(CMAKE_C_FLAGS "-masm=intel -std=gnu99 -fpack-struct=1" CACHE STRING "" FORCE)
|
||||
set(CMAKE_CXX_FLAGS "-masm=intel -std=c++0x -std=gnu++0x -fpack-struct=1" CACHE STRING "" FORCE)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-static-libgcc -static-libstdc++" CACHE STRING "" FORCE)
|
||||
|
||||
# find and include SDL2
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
@echo OFF
|
||||
pushd "%~dp0"
|
||||
IF NOT EXIST .\lib\libcurl\ (
|
||||
curl http://misozmiric.com/ted/openrct2/orcalibs-vs.zip -o .\lib\orcalibs.zip
|
||||
pushd .\lib
|
||||
unzip -oaq orcalibs.zip
|
||||
del .\orcalibs.zip
|
||||
popd
|
||||
)
|
||||
popd
|
|
@ -1 +1 @@
|
|||
msbuild .\projects\openrct2.vcxproj /p:Configuration=Release /p:Platform=x86
|
||||
msbuild .\projects\openrct2.sln /p:Configuration=Release /p:Platform=Win32
|
1
clean.sh
1
clean.sh
|
@ -3,5 +3,6 @@
|
|||
set -ev
|
||||
|
||||
sudo rm -rf /usr/local/cross-tools/i686-w64-mingw32
|
||||
sudo rm -rf /usr/local/cross-tools/orcalibs
|
||||
rm -rf .cache
|
||||
rm -rf build
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -3497,3 +3497,16 @@ STR_5160 :{MONTH} {STRINGID}, Year {COMMA16}
|
|||
STR_5161 :{WHITE}Date Format:
|
||||
STR_5162 :Day/Month/Year
|
||||
STR_5163 :Month/Day/Year
|
||||
STR_5164 :Twitch Channel name
|
||||
STR_5165 :Name peeps after followers
|
||||
STR_5166 :Will name peeps after channel's Twitch followers
|
||||
STR_5167 :Track follower peeps
|
||||
STR_5168 :Will turn on tracking information for guests named after channel's Twitch followers
|
||||
STR_5169 :Name peeps after people in Twitch chat
|
||||
STR_5170 :Will name peeps after people in Twitch chat
|
||||
STR_5171 :Track chat peeps
|
||||
STR_5172 :Will turn on tracking information for guests named after Twitch chat participants
|
||||
STR_5173 :Pull Twitch chat as news
|
||||
STR_5174 :Will use Twitch chat messages preceded by !news for in game notifications
|
||||
STR_5175 :Input the name of your Twitch channel
|
||||
STR_5176 :Enable Twitch integration
|
11
install.sh
11
install.sh
|
@ -84,6 +84,14 @@ if [[ ! -d $cachedir/SDL2-${SDL2_PV} ]]; then
|
|||
tar -xzf SDL2-devel-${SDL2_PV}-mingw.tar.gz
|
||||
popd
|
||||
fi
|
||||
if [[ ! -f $cachedir/orcalibs.zip ]]; then
|
||||
wget http://misozmiric.com/ted/openrct2/orcalibs-unix.zip --output-document $cachedir/orcalibs.zip;
|
||||
fi
|
||||
if [[ ! -d $cachedir/orcalibs ]]; then
|
||||
pushd $cachedir
|
||||
unzip -uaq orcalibs.zip
|
||||
popd
|
||||
fi
|
||||
|
||||
# Apply platform patch
|
||||
mingw_patch=libsdl2-mingw-2.0.3-fix-platform-detection-for-mingw.patch
|
||||
|
@ -103,6 +111,9 @@ fi
|
|||
if [[ ! -d /usr/local/cross-tools/i686-w64-mingw32 ]]; then
|
||||
sudo cp -r $cachedir/SDL2-${SDL2_PV}/i686-w64-mingw32 /usr/local/cross-tools/
|
||||
fi
|
||||
if [[ ! -d /usr/local/cross-tools/orcalibs ]]; then
|
||||
sudo cp -r $cachedir/orcalibs /usr/local/cross-tools/
|
||||
fi
|
||||
|
||||
if [[ ! -f $cachedir/i686-w64-mingw32-pkg-config ]]; then
|
||||
# If this fails to work because of newlines, be sure you are running this
|
||||
|
|
|
@ -41,10 +41,13 @@
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(SolutionDir)..\build\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\obj\$(ProjectName)\$(Configuration)\</IntDir>
|
||||
<IncludePath>..\..\lib\openssl\include;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)..\build\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\obj\$(ProjectName)\$(Configuration)\</IntDir>
|
||||
<IncludePath>..\..\lib\libcurl\include;..\..\lib\jansson;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>..\..\lib\libcurl\lib;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
|
@ -53,7 +56,7 @@
|
|||
<SDLCheck>true</SDLCheck>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<StructMemberAlignment>1Byte</StructMemberAlignment>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;NS_ENABLE_THREADS;NS_ENABLE_SSL;DISABLE_MD5;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
|
@ -66,21 +69,40 @@
|
|||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;NS_ENABLE_THREADS;NS_ENABLE_SSL;DISABLE_MD5;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<StructMemberAlignment>1Byte</StructMemberAlignment>
|
||||
<DebugInformationFormat>
|
||||
</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalDependencies>libcurl.lib;Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Lib>
|
||||
<PreBuildEvent>
|
||||
<Command>$(SolutionDir)..\VSgetLibs.bat</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\lib\argparse\argparse.c">
|
||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">TurnOffAllWarnings</WarningLevel>
|
||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">TurnOffAllWarnings</WarningLevel>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\lib\jansson\jansson\dump.c" />
|
||||
<ClCompile Include="..\..\lib\jansson\jansson\error.c" />
|
||||
<ClCompile Include="..\..\lib\jansson\jansson\hashtable.c" />
|
||||
<ClCompile Include="..\..\lib\jansson\jansson\hashtable_seed.c" />
|
||||
<ClCompile Include="..\..\lib\jansson\jansson\load.c" />
|
||||
<ClCompile Include="..\..\lib\jansson\jansson\memory.c" />
|
||||
<ClCompile Include="..\..\lib\jansson\jansson\pack_unpack.c" />
|
||||
<ClCompile Include="..\..\lib\jansson\jansson\strbuffer.c" />
|
||||
<ClCompile Include="..\..\lib\jansson\jansson\strconv.c" />
|
||||
<ClCompile Include="..\..\lib\jansson\jansson\utf.c" />
|
||||
<ClCompile Include="..\..\lib\jansson\jansson\value.c" />
|
||||
<ClCompile Include="..\..\lib\libspeex\resample.c">
|
||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">TurnOffAllWarnings</WarningLevel>
|
||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">TurnOffAllWarnings</WarningLevel>
|
||||
|
@ -89,6 +111,14 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\lib\argparse\argparse.h" />
|
||||
<ClInclude Include="..\..\lib\jansson\jansson\hashtable.h" />
|
||||
<ClInclude Include="..\..\lib\jansson\jansson\jansson.h" />
|
||||
<ClInclude Include="..\..\lib\jansson\jansson\jansson_private.h" />
|
||||
<ClInclude Include="..\..\lib\jansson\jansson\lookup3.h" />
|
||||
<ClInclude Include="..\..\lib\jansson\jansson\strbuffer.h" />
|
||||
<ClInclude Include="..\..\lib\jansson\jansson\utf.h" />
|
||||
<ClInclude Include="..\..\lib\jansson\jansson_config.h" />
|
||||
<ClInclude Include="..\..\lib\jansson\jansson_private_config.h" />
|
||||
<ClInclude Include="..\..\lib\libspeex\arch.h" />
|
||||
<ClInclude Include="..\..\lib\libspeex\config.h" />
|
||||
<ClInclude Include="..\..\lib\libspeex\os_support.h" />
|
||||
|
|
|
@ -13,6 +13,12 @@
|
|||
<Filter Include="lodepng">
|
||||
<UniqueIdentifier>{7f953e55-d294-4158-b309-67f41fa82760}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="libcurl">
|
||||
<UniqueIdentifier>{7b46a2d6-1095-4e7a-b98b-006b832ef7a1}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="jansson">
|
||||
<UniqueIdentifier>{16ee6cb9-307a-4e8a-8261-a69d91b17739}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\lib\argparse\argparse.c">
|
||||
|
@ -24,6 +30,39 @@
|
|||
<ClCompile Include="..\..\lib\lodepng\lodepng.c">
|
||||
<Filter>lodepng</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\lib\jansson\jansson\dump.c">
|
||||
<Filter>jansson</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\lib\jansson\jansson\error.c">
|
||||
<Filter>jansson</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\lib\jansson\jansson\hashtable.c">
|
||||
<Filter>jansson</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\lib\jansson\jansson\hashtable_seed.c">
|
||||
<Filter>jansson</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\lib\jansson\jansson\load.c">
|
||||
<Filter>jansson</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\lib\jansson\jansson\memory.c">
|
||||
<Filter>jansson</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\lib\jansson\jansson\pack_unpack.c">
|
||||
<Filter>jansson</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\lib\jansson\jansson\strbuffer.c">
|
||||
<Filter>jansson</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\lib\jansson\jansson\strconv.c">
|
||||
<Filter>jansson</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\lib\jansson\jansson\utf.c">
|
||||
<Filter>jansson</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\lib\jansson\jansson\value.c">
|
||||
<Filter>jansson</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\lib\argparse\argparse.h">
|
||||
|
@ -50,5 +89,29 @@
|
|||
<ClInclude Include="..\..\lib\lodepng\lodepng.h">
|
||||
<Filter>lodepng</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\lib\jansson\jansson_config.h">
|
||||
<Filter>jansson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\lib\jansson\jansson_private_config.h">
|
||||
<Filter>jansson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\lib\jansson\jansson\hashtable.h">
|
||||
<Filter>jansson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\lib\jansson\jansson\jansson.h">
|
||||
<Filter>jansson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\lib\jansson\jansson\jansson_private.h">
|
||||
<Filter>jansson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\lib\jansson\jansson\lookup3.h">
|
||||
<Filter>jansson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\lib\jansson\jansson\strbuffer.h">
|
||||
<Filter>jansson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\lib\jansson\jansson\utf.h">
|
||||
<Filter>jansson</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -2,6 +2,7 @@
|
|||
<Project DefaultTargets="Build0;Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Target Name="Build0">
|
||||
<Copy SourceFiles="..\openrct2.exe" DestinationFolder="$(OutDir)" />
|
||||
<Copy SourceFiles="..\curl-ca-bundle.crt" DestinationFolder="$(OutDir)" />
|
||||
<Copy SourceFiles="..\SDL2.dll" DestinationFolder="$(OutDir)" />
|
||||
</Target>
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
|
@ -15,6 +16,7 @@
|
|||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\curl-ca-bundle.crt" />
|
||||
<None Include="..\openrct2.exe" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -55,6 +57,8 @@
|
|||
<ClCompile Include="..\src\management\marketing.c" />
|
||||
<ClCompile Include="..\src\management\news_item.c" />
|
||||
<ClCompile Include="..\src\management\research.c" />
|
||||
<ClCompile Include="..\src\network\http.cpp" />
|
||||
<ClCompile Include="..\src\network\twitch.cpp" />
|
||||
<ClCompile Include="..\src\object.c" />
|
||||
<ClCompile Include="..\src\object_list.c" />
|
||||
<ClCompile Include="..\src\openrct2.c" />
|
||||
|
@ -182,6 +186,8 @@
|
|||
<ClInclude Include="..\src\management\marketing.h" />
|
||||
<ClInclude Include="..\src\management\news_item.h" />
|
||||
<ClInclude Include="..\src\management\research.h" />
|
||||
<ClInclude Include="..\src\network\http.h" />
|
||||
<ClInclude Include="..\src\network\twitch.h" />
|
||||
<ClInclude Include="..\src\object.h" />
|
||||
<ClInclude Include="..\src\openrct2.h" />
|
||||
<ClInclude Include="..\src\peep\peep.h" />
|
||||
|
@ -260,8 +266,8 @@
|
|||
<IntDir>$(SolutionDir)..\obj\$(ProjectName)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<IncludePath>$(SolutionDir)..\lib;$(SolutionDir)..\lib\libspeex;$(SolutionDir)..\lib\sdl\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(SolutionDir)..\lib\sdl\lib\x86;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>$(SolutionDir)..\lib;$(SolutionDir)..\lib\libspeex;$(SolutionDir)..\lib\sdl\include;$(SolutionDir)..\lib\libcurl\include;$(SolutionDir)..\lib\jansson;$(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>
|
||||
<CustomBuildBeforeTargets>
|
||||
|
@ -289,13 +295,13 @@
|
|||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>
|
||||
</SDLCheck>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<StructMemberAlignment>1Byte</StructMemberAlignment>
|
||||
<TreatSpecificWarningsAsErrors>4013</TreatSpecificWarningsAsErrors>
|
||||
<OmitFramePointers>
|
||||
</OmitFramePointers>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;CURL_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ObjectFileName>$(IntDir)fake\%(RelativeDir)</ObjectFileName>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
|
@ -304,6 +310,7 @@
|
|||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>winmm.lib;sdl2.lib;Dsound.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalOptions>/ignore:4099 %(AdditionalOptions)</AdditionalOptions>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>"$(TargetDir)\openrct2.exe" sprite build "$(SolutionDir)\..\Data\g2.dat" "$(SolutionDir)\..\Resources\g2\"
|
||||
|
|
|
@ -41,11 +41,17 @@
|
|||
<Filter Include="Source\Peep">
|
||||
<UniqueIdentifier>{51e38783-5334-464c-8f90-61d725dc8013}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source\Network">
|
||||
<UniqueIdentifier>{ae88ed08-902b-4167-a78c-9b521ce67749}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\openrct2.exe">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
<None Include="..\curl-ca-bundle.crt">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\management\award.c">
|
||||
|
@ -381,7 +387,6 @@
|
|||
<ClCompile Include="..\src\localisation\user.c">
|
||||
<Filter>Source\Localisation</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\lib\lodepng\lodepng.c" />
|
||||
<ClCompile Include="..\src\windows\editor_inventions_list.c">
|
||||
<Filter>Source\Windows</Filter>
|
||||
</ClCompile>
|
||||
|
@ -391,7 +396,6 @@
|
|||
<ClCompile Include="..\src\windows\editor_scenario_options.c">
|
||||
<Filter>Source\Windows</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\lib\lodepng\lodepng.c" />
|
||||
<ClCompile Include="..\src\world\map_helpers.c">
|
||||
<Filter>Source\World</Filter>
|
||||
</ClCompile>
|
||||
|
@ -440,6 +444,12 @@
|
|||
<ClCompile Include="..\src\interface\console.c">
|
||||
<Filter>Source\Interface</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\network\twitch.cpp">
|
||||
<Filter>Source\Network</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\network\http.cpp">
|
||||
<Filter>Source\Network</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\src\management\award.h">
|
||||
|
@ -646,5 +656,11 @@
|
|||
<ClInclude Include="..\src\interface\console.h">
|
||||
<Filter>Source\Interface</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\network\http.h">
|
||||
<Filter>Source\Network</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\network\twitch.h">
|
||||
<Filter>Source\Network</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -7,4 +7,7 @@
|
|||
<LocalDebuggerCommandArguments>
|
||||
</LocalDebuggerCommandArguments>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ShowAllFiles>false</ShowAllFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
Binary file not shown.
After Width: | Height: | Size: 403 B |
13
src/config.c
13
src/config.c
|
@ -197,11 +197,21 @@ config_property_definition _cheatDefinitions[] = {
|
|||
{ offsetof(cheat_configuration, unlock_all_prices), "unlock_all_prices", CONFIG_VALUE_TYPE_BOOLEAN, false, NULL },
|
||||
};
|
||||
|
||||
config_property_definition _twitchDefinitions[] = {
|
||||
{ offsetof(twitch_configuration, channel), "channel", CONFIG_VALUE_TYPE_STRING, { .value_string = NULL }, NULL },
|
||||
{ offsetof(twitch_configuration, enable_follower_peep_names), "follower_peep_names", CONFIG_VALUE_TYPE_BOOLEAN, true, NULL },
|
||||
{ offsetof(twitch_configuration, enable_follower_peep_tracking), "follower_peep_tracking", CONFIG_VALUE_TYPE_BOOLEAN, false, NULL },
|
||||
{ offsetof(twitch_configuration, enable_chat_peep_names), "chat_peep_names", CONFIG_VALUE_TYPE_BOOLEAN, true, NULL },
|
||||
{ offsetof(twitch_configuration, enable_chat_peep_tracking), "chat_peep_tracking", CONFIG_VALUE_TYPE_BOOLEAN, true, NULL },
|
||||
{ offsetof(twitch_configuration, enable_news), "news", CONFIG_VALUE_TYPE_BOOLEAN, false, NULL }
|
||||
};
|
||||
|
||||
config_section_definition _sectionDefinitions[] = {
|
||||
{ &gConfigGeneral, "general", _generalDefinitions, countof(_generalDefinitions) },
|
||||
{ &gConfigInterface, "interface", _interfaceDefinitions, countof(_interfaceDefinitions) },
|
||||
{ &gConfigSound, "sound", _soundDefinitions, countof(_soundDefinitions) },
|
||||
{ &gConfigCheat, "cheat", _cheatDefinitions, countof(_cheatDefinitions) }
|
||||
{ &gConfigCheat, "cheat", _cheatDefinitions, countof(_cheatDefinitions) },
|
||||
{ &gConfigTwitch, "twitch", _twitchDefinitions, countof(_twitchDefinitions) }
|
||||
};
|
||||
|
||||
#pragma endregion
|
||||
|
@ -210,6 +220,7 @@ general_configuration gConfigGeneral;
|
|||
interface_configuration gConfigInterface;
|
||||
sound_configuration gConfigSound;
|
||||
cheat_configuration gConfigCheat;
|
||||
twitch_configuration gConfigTwitch;
|
||||
|
||||
bool config_open(const utf8string path);
|
||||
bool config_save(const utf8string path);
|
||||
|
|
|
@ -165,6 +165,14 @@ typedef struct {
|
|||
uint8 unlock_all_prices;
|
||||
} cheat_configuration;
|
||||
|
||||
typedef struct {
|
||||
utf8string channel;
|
||||
uint8 enable_follower_peep_names;
|
||||
uint8 enable_follower_peep_tracking;
|
||||
uint8 enable_chat_peep_names;
|
||||
uint8 enable_chat_peep_tracking;
|
||||
uint8 enable_news;
|
||||
} twitch_configuration;
|
||||
|
||||
typedef struct {
|
||||
uint8 key;
|
||||
|
@ -175,6 +183,7 @@ extern general_configuration gConfigGeneral;
|
|||
extern interface_configuration gConfigInterface;
|
||||
extern sound_configuration gConfigSound;
|
||||
extern cheat_configuration gConfigCheat;
|
||||
extern twitch_configuration gConfigTwitch;
|
||||
|
||||
extern uint16 gShortcutKeys[SHORTCUT_COUNT];
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <stdarg.h>
|
||||
#include <SDL_scancode.h>
|
||||
|
||||
#include "../addresses.h"
|
||||
#include "../drawing/drawing.h"
|
||||
#include "../localisation/localisation.h"
|
||||
|
@ -10,11 +11,12 @@
|
|||
#include "../cursors.h"
|
||||
#include "../game.h"
|
||||
#include "../input.h"
|
||||
#include "../network/twitch.h"
|
||||
#include "../object.h"
|
||||
#include "console.h"
|
||||
#include "window.h"
|
||||
#include "../world/scenery.h"
|
||||
#include "../management/research.h"
|
||||
#include "console.h"
|
||||
#include "window.h"
|
||||
|
||||
#define CONSOLE_BUFFER_SIZE 8192
|
||||
#define CONSOLE_BUFFER_2_SIZE 256
|
||||
|
@ -635,6 +637,15 @@ static int cc_set(const char **argv, int argc)
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
static int cc_twitch(const char **argv, int argc)
|
||||
{
|
||||
#ifdef DISABLE_TWITCH
|
||||
console_writeline_error("OpenRCT2 build not compiled with Twitch integeration.");
|
||||
#else
|
||||
// TODO add some twitch commands
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
static void editor_load_selected_objects_console()
|
||||
{
|
||||
uint8 *selection_flags = RCT2_GLOBAL(RCT2_ADDRESS_EDITOR_OBJECT_FLAGS_LIST, uint8*);
|
||||
|
@ -694,7 +705,6 @@ static int cc_load_object(const char **argv, int argc) {
|
|||
reset_loaded_objects();
|
||||
if (type == OBJECT_TYPE_RIDE) {
|
||||
// Automatically research the ride so it's supported by the game.
|
||||
|
||||
rct_ride_type *rideEntry;
|
||||
int rideType;
|
||||
|
||||
|
@ -833,7 +843,8 @@ console_command console_command_table[] = {
|
|||
"Loading a scenery group will not load its associated objects.\n"
|
||||
"This is a safer method opposed to \"open object_selection\".",
|
||||
"load_object <objectfilenodat>" },
|
||||
{ "object_count", cc_object_count, "Shows the number of objects of each type in the scenario.", "object_count" }
|
||||
{ "object_count", cc_object_count, "Shows the number of objects of each type in the scenario.", "object_count" },
|
||||
{ "twitch", cc_twitch, "Twitch API" }
|
||||
};
|
||||
|
||||
static int cc_windows(const char **argv, int argc) {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define _CONSOLE_H_
|
||||
|
||||
#include "../common.h"
|
||||
#include "../drawing/drawing.h"
|
||||
|
||||
extern bool gConsoleOpen;
|
||||
|
||||
|
|
|
@ -561,6 +561,7 @@ void window_publisher_credits_open();
|
|||
void window_track_manage_open();
|
||||
void window_viewport_open();
|
||||
void window_text_input_open(rct_window* call_w, int call_widget, rct_string_id title, rct_string_id description, rct_string_id existing_text, uint32 existing_args, int maxLength);
|
||||
void window_text_input_raw_open(rct_window* call_w, int call_widget, rct_string_id title, rct_string_id description, utf8string existing_text, int maxLength);
|
||||
rct_window *window_mapgen_open();
|
||||
rct_window *window_loadsave_open(int type);
|
||||
|
||||
|
|
|
@ -1408,6 +1408,20 @@ enum {
|
|||
|
||||
STR_OPENRCT2_BEGIN_STRING_ID = 5120,
|
||||
|
||||
STR_TWITCH_NAME = 5164,
|
||||
STR_TWITCH_PEEP_FOLLOWERS = 5165,
|
||||
STR_TWITCH_PEEP_FOLLOWERS_TIP = 5166,
|
||||
STR_TWITCH_FOLLOWERS_TRACK = 5167,
|
||||
STR_TWITCH_FOLLOWERS_TRACK_TIP = 5168,
|
||||
STR_TWITCH_PEEP_CHAT = 5169,
|
||||
STR_TWITCH_PEEP_CHAT_TIP = 5170,
|
||||
STR_TWITCH_CHAT_TRACK = 5171,
|
||||
STR_TWITCH_CHAT_TRACK_TIP = 5172,
|
||||
STR_TWITCH_CHAT_NEWS = 5173,
|
||||
STR_TWITCH_CHAT_NEWS_TIP = 5174,
|
||||
STR_TWITCH_NAME_DESC = 5175,
|
||||
STR_TWITCH_ENABLE = 5176,
|
||||
|
||||
// Have to include resource strings (from scenarios and objects) for the time being now that language is partially working
|
||||
STR_COUNT = 32768
|
||||
};
|
||||
|
|
|
@ -249,6 +249,15 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int *
|
|||
* @param c (ecx)
|
||||
**/
|
||||
void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc)
|
||||
{
|
||||
char *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)
|
||||
{
|
||||
int i = 0;
|
||||
rct_news_item *newsItem = RCT2_ADDRESS(RCT2_ADDRESS_NEWS_ITEM_LIST, rct_news_item);
|
||||
|
@ -268,10 +277,8 @@ void news_item_add_to_queue(uint8 type, rct_string_id string_id, 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;
|
||||
|
||||
format_string((char*)0x0141EF68, string_id, (void*)0x013CE952); // overflows possible?
|
||||
newsItem->colour = ((char*)0x0141EF68)[0];
|
||||
strncpy(newsItem->text, (char*)0x0141EF68, 255);
|
||||
newsItem->colour = text[0];
|
||||
strncpy(newsItem->text, text + 1, 254);
|
||||
newsItem->text[254] = 0;
|
||||
|
||||
// blatant disregard for what happens on the last element.
|
||||
|
|
|
@ -57,6 +57,7 @@ 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_open_subject(int type, int subject);
|
||||
void news_item_disable_news(uint8 type, uint32 assoc);
|
||||
|
||||
|
|
|
@ -0,0 +1,147 @@
|
|||
extern "C" {
|
||||
#include "http.h"
|
||||
}
|
||||
|
||||
#ifdef DISABLE_HTTP
|
||||
|
||||
void http_init() { }
|
||||
void http_dispose() { }
|
||||
|
||||
#else
|
||||
|
||||
#include <SDL.h>
|
||||
#include <curl/curl.h>
|
||||
#include <jansson/jansson.h>
|
||||
|
||||
typedef struct {
|
||||
char *ptr;
|
||||
int length;
|
||||
int capacity;
|
||||
} write_buffer;
|
||||
|
||||
void http_init()
|
||||
{
|
||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
}
|
||||
|
||||
void http_dispose()
|
||||
{
|
||||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
static size_t http_request_write_func(void *ptr, size_t size, size_t nmemb, void *userdata)
|
||||
{
|
||||
write_buffer *writeBuffer = (write_buffer*)userdata;
|
||||
|
||||
int newBytesLength = size * nmemb;
|
||||
if (newBytesLength > 0) {
|
||||
int newCapacity = writeBuffer->capacity;
|
||||
int newLength = writeBuffer->length + newBytesLength;
|
||||
while (newLength > newCapacity) {
|
||||
newCapacity = max(4096, newCapacity * 2);
|
||||
}
|
||||
if (newCapacity != writeBuffer->capacity) {
|
||||
writeBuffer->ptr = (char*)realloc(writeBuffer->ptr, newCapacity);
|
||||
writeBuffer->capacity = newCapacity;
|
||||
}
|
||||
|
||||
memcpy(writeBuffer->ptr + writeBuffer->length, ptr, newBytesLength);
|
||||
writeBuffer->length = newLength;
|
||||
}
|
||||
return newBytesLength;
|
||||
}
|
||||
|
||||
http_json_response *http_request_json(const char *url)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode curlResult;
|
||||
http_json_response *response;
|
||||
write_buffer writeBuffer;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if (curl == NULL)
|
||||
return NULL;
|
||||
|
||||
writeBuffer.ptr = NULL;
|
||||
writeBuffer.length = 0;
|
||||
writeBuffer.capacity = 0;
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, TRUE);
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, TRUE);
|
||||
curl_easy_setopt(curl, CURLOPT_CAINFO, "curl-ca-bundle.crt");
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &writeBuffer);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, http_request_write_func);
|
||||
|
||||
curlResult = curl_easy_perform(curl);
|
||||
if (curlResult != CURLE_OK) {
|
||||
log_error("HTTP request failed: %s.", curl_easy_strerror(curlResult));
|
||||
if (writeBuffer.ptr != NULL)
|
||||
free(writeBuffer.ptr);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
long httpStatusCode;
|
||||
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpStatusCode);
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
// Null terminate the response buffer
|
||||
writeBuffer.length++;
|
||||
writeBuffer.ptr = (char*)realloc(writeBuffer.ptr, writeBuffer.length);
|
||||
writeBuffer.capacity = writeBuffer.length;
|
||||
writeBuffer.ptr[writeBuffer.length - 1] = 0;
|
||||
|
||||
response = NULL;
|
||||
|
||||
// Parse as JSON
|
||||
json_t *root;
|
||||
json_error_t error;
|
||||
root = json_loads(writeBuffer.ptr, 0, &error);
|
||||
if (root != NULL) {
|
||||
response = (http_json_response*)malloc(sizeof(http_json_response));
|
||||
response->status_code = (int)httpStatusCode;
|
||||
response->root = root;
|
||||
}
|
||||
free(writeBuffer.ptr);
|
||||
return response;
|
||||
}
|
||||
|
||||
void http_request_json_async(const char *url, void (*callback)(http_json_response*))
|
||||
{
|
||||
struct TempThreadArgs {
|
||||
const char *url;
|
||||
void (*callback)(http_json_response*);
|
||||
};
|
||||
|
||||
TempThreadArgs *args = (TempThreadArgs*)malloc(sizeof(TempThreadArgs));
|
||||
args->url = url;
|
||||
args->callback = callback;
|
||||
|
||||
SDL_Thread *thread = SDL_CreateThread([](void *ptr) -> int {
|
||||
TempThreadArgs *args = (TempThreadArgs*)ptr;
|
||||
|
||||
http_json_response *response = http_request_json(args->url);
|
||||
args->callback(response);
|
||||
free(args);
|
||||
return 0;
|
||||
}, NULL, args);
|
||||
|
||||
if (thread == NULL) {
|
||||
log_error("Unable to create thread!");
|
||||
callback(NULL);
|
||||
} else {
|
||||
SDL_DetachThread(thread);
|
||||
}
|
||||
}
|
||||
|
||||
void http_request_json_dispose(http_json_response *response)
|
||||
{
|
||||
if (response->root != NULL)
|
||||
json_decref(response->root);
|
||||
|
||||
free(response);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,18 @@
|
|||
#ifndef _HTTP_H_
|
||||
#define _HTTP_H_
|
||||
|
||||
#include <jansson/jansson.h>
|
||||
#include "../common.h"
|
||||
|
||||
typedef struct {
|
||||
int status_code;
|
||||
json_t *root;
|
||||
} http_json_response;
|
||||
|
||||
void http_init();
|
||||
void http_dispose();
|
||||
http_json_response *http_request_json(const char *url);
|
||||
void http_request_json_async(const char *url, void (*callback)(http_json_response*));
|
||||
void http_request_json_dispose(http_json_response *response);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,435 @@
|
|||
#ifdef DISABLE_TWITCH
|
||||
|
||||
extern "C" {
|
||||
#include "twitch.h"
|
||||
}
|
||||
|
||||
void twitch_update() { }
|
||||
|
||||
#else
|
||||
|
||||
// REQUIRES HTTP
|
||||
|
||||
#include <vector>
|
||||
#include <SDL.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
#include "../addresses.h"
|
||||
#include "../config.h"
|
||||
#include "../interface/console.h"
|
||||
#include "../localisation/localisation.h"
|
||||
#include "../management/news_item.h"
|
||||
#include "../peep/peep.h"
|
||||
#include "../world/sprite.h"
|
||||
#include "http.h"
|
||||
#include "twitch.h"
|
||||
|
||||
}
|
||||
|
||||
enum {
|
||||
TWITCH_STATE_JOINING,
|
||||
TWITCH_STATE_JOINED,
|
||||
TWITCH_STATE_WAITING,
|
||||
TWITCH_STATE_GET_FOLLOWERS,
|
||||
TWITCH_STATE_GET_MESSAGES,
|
||||
TWITCH_STATE_LEAVING,
|
||||
TWITCH_STATE_LEFT
|
||||
};
|
||||
|
||||
// The time between HTTP requests.
|
||||
// TODO Ideally, the chat message pulse should be more frequent than the followers / chat members so that news messages etc.
|
||||
// have a lower latency.
|
||||
#define PULSE_TIME (10 * 1000)
|
||||
|
||||
const char *TwitchExtendedBaseUrl = "http://openrct.ursalabs.co/api/1/";
|
||||
|
||||
bool gTwitchEnable = false;
|
||||
|
||||
static int _twitchState = TWITCH_STATE_LEFT;
|
||||
static bool _twitchIdle = true;
|
||||
static uint32 _twitchLastPulseTick = 0;
|
||||
static int _twitchLastPulseOperation = 1;
|
||||
static http_json_response *_twitchJsonResponse;
|
||||
|
||||
static void twitch_join();
|
||||
static void twitch_leave();
|
||||
static void twitch_get_followers();
|
||||
static void twitch_get_messages();
|
||||
|
||||
static void twitch_parse_followers();
|
||||
static void twitch_parse_messages();
|
||||
static void twitch_parse_chat_message(const char *message);
|
||||
|
||||
void twitch_update()
|
||||
{
|
||||
if (!_twitchIdle)
|
||||
return;
|
||||
|
||||
bool twitchable =
|
||||
!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & (~SCREEN_FLAGS_PLAYING)) &&
|
||||
gConfigTwitch.channel != NULL &&
|
||||
gConfigTwitch.channel[0] != 0 &&
|
||||
gTwitchEnable;
|
||||
|
||||
if (twitchable) {
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0)
|
||||
return;
|
||||
|
||||
switch (_twitchState) {
|
||||
case TWITCH_STATE_LEFT:
|
||||
{
|
||||
uint32 currentTime = SDL_GetTicks();
|
||||
uint32 timeSinceLastPulse = currentTime - _twitchLastPulseTick;
|
||||
if (_twitchLastPulseTick == 0 || timeSinceLastPulse > PULSE_TIME) {
|
||||
_twitchLastPulseTick = currentTime;
|
||||
twitch_join();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TWITCH_STATE_JOINED:
|
||||
{
|
||||
uint32 currentTime = SDL_GetTicks();
|
||||
uint32 timeSinceLastPulse = currentTime - _twitchLastPulseTick;
|
||||
if (_twitchLastPulseTick == 0 || timeSinceLastPulse > PULSE_TIME) {
|
||||
_twitchLastPulseTick = currentTime;
|
||||
_twitchLastPulseOperation = (_twitchLastPulseOperation + 1) % 2;
|
||||
switch (_twitchLastPulseOperation + TWITCH_STATE_GET_FOLLOWERS) {
|
||||
case TWITCH_STATE_GET_FOLLOWERS:
|
||||
twitch_get_followers();
|
||||
break;
|
||||
case TWITCH_STATE_GET_MESSAGES:
|
||||
if (gConfigTwitch.enable_news)
|
||||
twitch_get_messages();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TWITCH_STATE_GET_FOLLOWERS:
|
||||
twitch_parse_followers();
|
||||
break;
|
||||
case TWITCH_STATE_GET_MESSAGES:
|
||||
twitch_parse_messages();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (_twitchState != TWITCH_STATE_LEFT)
|
||||
twitch_leave();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /leave/:join
|
||||
*/
|
||||
static void twitch_join()
|
||||
{
|
||||
char url[256];
|
||||
sprintf(url, "%sjoin/%s", TwitchExtendedBaseUrl, gConfigTwitch.channel);
|
||||
|
||||
_twitchState = TWITCH_STATE_JOINING;
|
||||
_twitchIdle = false;
|
||||
http_request_json_async(url, [](http_json_response *jsonResponse) -> void {
|
||||
if (jsonResponse == NULL) {
|
||||
_twitchState = TWITCH_STATE_LEFT;
|
||||
console_writeline("Unable to connect to twitch channel.");
|
||||
} else {
|
||||
json_t *jsonStatus = json_object_get(jsonResponse->root, "status");
|
||||
if (json_is_number(jsonStatus) && json_integer_value(jsonStatus) == 200)
|
||||
_twitchState = TWITCH_STATE_JOINED;
|
||||
else
|
||||
_twitchState = TWITCH_STATE_LEFT;
|
||||
|
||||
http_request_json_dispose(jsonResponse);
|
||||
|
||||
_twitchLastPulseTick = 0;
|
||||
console_writeline("Connected to twitch channel.");
|
||||
}
|
||||
_twitchIdle = true;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /leave/:channel
|
||||
*/
|
||||
static void twitch_leave()
|
||||
{
|
||||
if (_twitchJsonResponse != NULL) {
|
||||
http_request_json_dispose(_twitchJsonResponse);
|
||||
_twitchJsonResponse = NULL;
|
||||
}
|
||||
|
||||
console_writeline("Left twitch channel.");
|
||||
_twitchState = TWITCH_STATE_LEFT;
|
||||
_twitchLastPulseTick = 0;
|
||||
gTwitchEnable = false;
|
||||
|
||||
// TODO reset all peeps with twitch flag
|
||||
|
||||
// HTTP request no longer used as it could be abused
|
||||
// char url[256];
|
||||
// sprintf(url, "%sleave/%s", TwitchExtendedBaseUrl, gConfigTwitch.channel);
|
||||
// _twitchState = TWITCH_STATE_LEAVING;
|
||||
// _twitchIdle = false;
|
||||
// http_request_json_async(url, [](http_json_response *jsonResponse) -> void {
|
||||
// http_request_json_dispose(jsonResponse);
|
||||
// _twitchState = TWITCH_STATE_LEFT;
|
||||
// _twitchIdle = true;
|
||||
//
|
||||
// console_writeline("Left twitch channel.");
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /channel/:channel/audience
|
||||
*/
|
||||
static void twitch_get_followers()
|
||||
{
|
||||
char url[256];
|
||||
sprintf(url, "%schannel/%s/audience", TwitchExtendedBaseUrl, gConfigTwitch.channel);
|
||||
|
||||
_twitchState = TWITCH_STATE_WAITING;
|
||||
_twitchIdle = false;
|
||||
http_request_json_async(url, [](http_json_response *jsonResponse) -> void {
|
||||
if (jsonResponse == NULL) {
|
||||
_twitchState = TWITCH_STATE_JOINED;
|
||||
} else {
|
||||
_twitchJsonResponse = jsonResponse;
|
||||
_twitchState = TWITCH_STATE_GET_FOLLOWERS;
|
||||
}
|
||||
_twitchIdle = true;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /channel/:channel/messages
|
||||
*/
|
||||
static void twitch_get_messages()
|
||||
{
|
||||
char url[256];
|
||||
sprintf(url, "%schannel/%s/messages", TwitchExtendedBaseUrl, gConfigTwitch.channel);
|
||||
|
||||
_twitchState = TWITCH_STATE_WAITING;
|
||||
_twitchIdle = false;
|
||||
http_request_json_async(url, [](http_json_response *jsonResponse) -> void {
|
||||
if (jsonResponse == NULL) {
|
||||
_twitchState = TWITCH_STATE_JOINED;
|
||||
} else {
|
||||
_twitchJsonResponse = jsonResponse;
|
||||
_twitchState = TWITCH_STATE_GET_MESSAGES;
|
||||
}
|
||||
_twitchIdle = true;
|
||||
});
|
||||
}
|
||||
|
||||
static void twitch_parse_followers()
|
||||
{
|
||||
struct AudienceMember {
|
||||
const char *name;
|
||||
bool isFollower;
|
||||
bool isInChat;
|
||||
bool isMod;
|
||||
bool exists;
|
||||
bool shouldTrack;
|
||||
};
|
||||
|
||||
std::vector<AudienceMember> members;
|
||||
|
||||
http_json_response *jsonResponse = _twitchJsonResponse;
|
||||
if (json_is_array(jsonResponse->root)) {
|
||||
int audienceCount = json_array_size(jsonResponse->root);
|
||||
for (int i = 0; i < audienceCount; i++) {
|
||||
json_t *audienceMember = json_array_get(jsonResponse->root, i);
|
||||
if (!json_is_object(audienceMember))
|
||||
continue;
|
||||
|
||||
json_t *name = json_object_get(audienceMember, "name");
|
||||
json_t *isFollower = json_object_get(audienceMember, "isFollower");
|
||||
json_t *isInChat = json_object_get(audienceMember, "inChat");
|
||||
json_t *isMod = json_object_get(audienceMember, "isMod");
|
||||
|
||||
AudienceMember member;
|
||||
member.name = json_string_value(name);
|
||||
member.isFollower = json_boolean_value(isFollower);
|
||||
member.isInChat = json_boolean_value(isInChat);
|
||||
member.isMod = json_boolean_value(isMod);
|
||||
member.exists = false;
|
||||
member.shouldTrack = false;
|
||||
|
||||
if (member.name == NULL || member.name[0] == 0)
|
||||
continue;
|
||||
|
||||
if (member.isInChat && gConfigTwitch.enable_chat_peep_tracking)
|
||||
member.shouldTrack = true;
|
||||
else if (member.isFollower && gConfigTwitch.enable_follower_peep_tracking)
|
||||
member.shouldTrack = true;
|
||||
|
||||
if (gConfigTwitch.enable_chat_peep_names && member.isInChat)
|
||||
members.push_back(member);
|
||||
else if (gConfigTwitch.enable_follower_peep_names && member.isFollower)
|
||||
members.push_back(member);
|
||||
}
|
||||
|
||||
uint16 spriteIndex;
|
||||
rct_peep *peep;
|
||||
char buffer[256];
|
||||
|
||||
// Check what followers are already in the park
|
||||
FOR_ALL_GUESTS(spriteIndex, peep) {
|
||||
if (is_user_string_id(peep->name_string_idx)) {
|
||||
format_string(buffer, peep->name_string_idx, NULL);
|
||||
|
||||
AudienceMember *member = NULL;
|
||||
for (size_t i = 0; i < members.size(); i++) {
|
||||
if (_strcmpi(buffer, members[i].name) == 0) {
|
||||
member = &members[i];
|
||||
members[i].exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (peep->flags & PEEP_FLAGS_TWITCH) {
|
||||
if (member == NULL) {
|
||||
// Member no longer peep name worthy
|
||||
peep->flags &= ~(PEEP_FLAGS_TRACKING | PEEP_FLAGS_TWITCH);
|
||||
|
||||
// TODO set peep name back to number / real name
|
||||
} else {
|
||||
if (member->shouldTrack)
|
||||
peep->flags |= (PEEP_FLAGS_TRACKING);
|
||||
else if (!member->shouldTrack)
|
||||
peep->flags &= ~(PEEP_FLAGS_TRACKING);
|
||||
}
|
||||
} else if (member != NULL && !(peep->flags & PEEP_FLAGS_LEAVING_PARK)) {
|
||||
// Peep with same name already exists but not twitch
|
||||
peep->flags |= PEEP_FLAGS_TWITCH;
|
||||
if (member->shouldTrack)
|
||||
peep->flags |= PEEP_FLAGS_TRACKING;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Rename non-named peeps to followers that aren't currently in the park.
|
||||
if (members.size() > 0) {
|
||||
int memberIndex = -1;
|
||||
FOR_ALL_GUESTS(spriteIndex, peep) {
|
||||
int originalMemberIndex = memberIndex;
|
||||
for (size_t i = memberIndex + 1; i < members.size(); i++) {
|
||||
if (!members[i].exists) {
|
||||
memberIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (originalMemberIndex == memberIndex)
|
||||
break;
|
||||
|
||||
AudienceMember *member = &members[memberIndex];
|
||||
if (!is_user_string_id(peep->name_string_idx) && !(peep->flags & PEEP_FLAGS_LEAVING_PARK)) {
|
||||
// Rename peep and add flags
|
||||
rct_string_id newStringId = user_string_allocate(4, member->name);
|
||||
if (newStringId != 0) {
|
||||
peep->name_string_idx = newStringId;
|
||||
peep->flags |= PEEP_FLAGS_TWITCH;
|
||||
if (member->shouldTrack)
|
||||
peep->flags |= PEEP_FLAGS_TRACKING;
|
||||
}
|
||||
} else {
|
||||
// Peep still yet to be found for member
|
||||
memberIndex--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
http_request_json_dispose(_twitchJsonResponse);
|
||||
_twitchJsonResponse = NULL;
|
||||
_twitchState = TWITCH_STATE_JOINED;
|
||||
|
||||
gfx_invalidate_screen();
|
||||
}
|
||||
|
||||
static void twitch_parse_messages()
|
||||
{
|
||||
http_json_response *jsonResponse = _twitchJsonResponse;
|
||||
if (json_is_array(jsonResponse->root)) {
|
||||
int messageCount = json_array_size(jsonResponse->root);
|
||||
for (int i = 0; i < messageCount; i++) {
|
||||
json_t *jsonMessage = json_array_get(jsonResponse->root, i);
|
||||
if (!json_is_object(jsonMessage))
|
||||
continue;
|
||||
|
||||
json_t *jsonText = json_object_get(jsonMessage, "message");
|
||||
const char *text = json_string_value(jsonText);
|
||||
|
||||
twitch_parse_chat_message(text);
|
||||
}
|
||||
}
|
||||
|
||||
http_request_json_dispose(_twitchJsonResponse);
|
||||
_twitchJsonResponse = NULL;
|
||||
_twitchState = TWITCH_STATE_JOINED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Like strchr but allows searching for one of many characters.
|
||||
*/
|
||||
static char *strchrm(const char *str, const char *find)
|
||||
{
|
||||
const char *result = NULL;
|
||||
do {
|
||||
const char *fch = find;
|
||||
while (*fch != 0) {
|
||||
if (*str == *fch)
|
||||
return (char*)str;
|
||||
|
||||
fch++;
|
||||
}
|
||||
} while (*str++ != 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *strskipwhitespace(const char *str)
|
||||
{
|
||||
while (*str == ' ' || *str == '\t')
|
||||
str++;
|
||||
|
||||
return (char*)str;
|
||||
}
|
||||
|
||||
static void twitch_parse_chat_message(const char *message)
|
||||
{
|
||||
char buffer[256], *ch;
|
||||
|
||||
message = strskipwhitespace(message);
|
||||
if (message[0] != '!')
|
||||
return;
|
||||
|
||||
message++;
|
||||
ch = strchrm(message, " \t");
|
||||
strncpy(buffer, message, ch - message);
|
||||
buffer[ch - message] = 0;
|
||||
if (_strcmpi(buffer, "news") == 0) {
|
||||
if (gConfigTwitch.enable_news) {
|
||||
ch = strskipwhitespace(ch);
|
||||
|
||||
buffer[0] = (char)FORMAT_TOPAZ;
|
||||
strncpy(buffer + 1, ch, sizeof(buffer) - 2);
|
||||
buffer[sizeof(buffer) - 2] = 0;
|
||||
|
||||
// Remove unsupport characters
|
||||
// TODO allow when OpenRCT2 gains unicode support
|
||||
ch = buffer;
|
||||
while (ch[0] != 0) {
|
||||
if ((unsigned char)ch[0] < 32 || (unsigned char)ch[0] > 122) {
|
||||
ch[0] = ' ';
|
||||
}
|
||||
ch++;
|
||||
}
|
||||
|
||||
// TODO Create a new news item type for twitch which has twitch icon
|
||||
news_item_add_to_queue_raw(NEWS_ITEM_BLANK, buffer, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef _TWITCH_H_
|
||||
#define _TWITCH_H_
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
extern bool gTwitchEnable;
|
||||
|
||||
void twitch_update();
|
||||
|
||||
#endif
|
|
@ -25,6 +25,7 @@
|
|||
#include "config.h"
|
||||
#include "editor.h"
|
||||
#include "localisation/localisation.h"
|
||||
#include "network/http.h"
|
||||
#include "openrct2.h"
|
||||
#include "platform/platform.h"
|
||||
#include "util/sawyercoding.h"
|
||||
|
@ -141,6 +142,7 @@ void openrct2_launch()
|
|||
audio_get_devices();
|
||||
get_dsound_devices();
|
||||
language_open(gConfigGeneral.language);
|
||||
http_init();
|
||||
if (!rct2_init())
|
||||
return;
|
||||
|
||||
|
@ -174,6 +176,8 @@ void openrct2_launch()
|
|||
|
||||
log_verbose("begin openrct2 loop");
|
||||
openrct2_loop();
|
||||
|
||||
http_dispose();
|
||||
platform_free();
|
||||
|
||||
// HACK Some threads are still running which causes the game to not terminate. Investigation required!
|
||||
|
|
|
@ -269,7 +269,9 @@ enum PEEP_FLAGS {
|
|||
|
||||
PEEP_FLAGS_JOY = (1 << 23), // Makes the peep jump in joy
|
||||
PEEP_FLAGS_ANGRY = (1 << 24),
|
||||
PEEP_FLAGS_ICE_CREAM = (1 << 25) // Unconfirmed
|
||||
PEEP_FLAGS_ICE_CREAM = (1 << 25), // Unconfirmed
|
||||
|
||||
PEEP_FLAGS_TWITCH = (1 << 31) // Added for twitch integration
|
||||
};
|
||||
|
||||
enum PEEP_NAUSEA_TOLERANCE {
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "localisation/date.h"
|
||||
#include "localisation/localisation.h"
|
||||
#include "management/news_item.h"
|
||||
#include "network/twitch.h"
|
||||
#include "object.h"
|
||||
#include "openrct2.h"
|
||||
#include "platform/platform.h"
|
||||
|
@ -346,6 +347,7 @@ void rct2_update_2()
|
|||
else
|
||||
game_update();
|
||||
|
||||
twitch_update();
|
||||
console_update();
|
||||
console_draw(RCT2_ADDRESS(RCT2_ADDRESS_SCREEN_DPI, rct_drawpixelinfo));
|
||||
}
|
||||
|
|
181
src/sprites.h
181
src/sprites.h
|
@ -253,105 +253,106 @@ enum {
|
|||
SPR_TAB_OBJECTIVE_15 = SPR_TAB_OBJECTIVE_0 + 15,
|
||||
|
||||
SPR_TAB_AWARDS = 5527,
|
||||
SPR_TAB_QUESTION = 5528,
|
||||
SPR_TAB_QUESTION = 5528,
|
||||
|
||||
SPR_TAB_GUESTS_0 = 5568,
|
||||
SPR_TAB_GUESTS_1 = SPR_TAB_GUESTS_0 + 1,
|
||||
SPR_TAB_GUESTS_2 = SPR_TAB_GUESTS_0 + 2,
|
||||
SPR_TAB_GUESTS_3 = SPR_TAB_GUESTS_0 + 3,
|
||||
SPR_TAB_GUESTS_4 = SPR_TAB_GUESTS_0 + 4,
|
||||
SPR_TAB_GUESTS_5 = SPR_TAB_GUESTS_0 + 5,
|
||||
SPR_TAB_GUESTS_6 = SPR_TAB_GUESTS_0 + 6,
|
||||
SPR_TAB_GUESTS_7 = SPR_TAB_GUESTS_0 + 7,
|
||||
SPR_TAB_GUESTS_8 = SPR_TAB_GUESTS_0 + 8,
|
||||
SPR_TAB_GUESTS_9 = SPR_TAB_GUESTS_0 + 9,
|
||||
SPR_TAB_GUESTS_10 = SPR_TAB_GUESTS_0 + 10,
|
||||
SPR_TAB_GUESTS_11 = SPR_TAB_GUESTS_0 + 11,
|
||||
SPR_TAB_GUESTS_12 = SPR_TAB_GUESTS_0 + 12,
|
||||
SPR_TAB_GUESTS_13 = SPR_TAB_GUESTS_0 + 13,
|
||||
SPR_TAB_GUESTS_14 = SPR_TAB_GUESTS_0 + 14,
|
||||
SPR_TAB_GUESTS_15 = SPR_TAB_GUESTS_0 + 15,
|
||||
SPR_TAB_GUESTS_0 = 5568,
|
||||
SPR_TAB_GUESTS_1 = SPR_TAB_GUESTS_0 + 1,
|
||||
SPR_TAB_GUESTS_2 = SPR_TAB_GUESTS_0 + 2,
|
||||
SPR_TAB_GUESTS_3 = SPR_TAB_GUESTS_0 + 3,
|
||||
SPR_TAB_GUESTS_4 = SPR_TAB_GUESTS_0 + 4,
|
||||
SPR_TAB_GUESTS_5 = SPR_TAB_GUESTS_0 + 5,
|
||||
SPR_TAB_GUESTS_6 = SPR_TAB_GUESTS_0 + 6,
|
||||
SPR_TAB_GUESTS_7 = SPR_TAB_GUESTS_0 + 7,
|
||||
SPR_TAB_GUESTS_8 = SPR_TAB_GUESTS_0 + 8,
|
||||
SPR_TAB_GUESTS_9 = SPR_TAB_GUESTS_0 + 9,
|
||||
SPR_TAB_GUESTS_10 = SPR_TAB_GUESTS_0 + 10,
|
||||
SPR_TAB_GUESTS_11 = SPR_TAB_GUESTS_0 + 11,
|
||||
SPR_TAB_GUESTS_12 = SPR_TAB_GUESTS_0 + 12,
|
||||
SPR_TAB_GUESTS_13 = SPR_TAB_GUESTS_0 + 13,
|
||||
SPR_TAB_GUESTS_14 = SPR_TAB_GUESTS_0 + 14,
|
||||
SPR_TAB_GUESTS_15 = SPR_TAB_GUESTS_0 + 15,
|
||||
|
||||
SPR_FLOOR_TEXTURE_GRASS = 5579,
|
||||
SPR_FLOOR_TEXTURE_SAND = SPR_FLOOR_TEXTURE_GRASS + 1,
|
||||
SPR_FLOOR_TEXTURE_DIRT = SPR_FLOOR_TEXTURE_GRASS + 2,
|
||||
SPR_FLOOR_TEXTURE_ROCK = SPR_FLOOR_TEXTURE_GRASS + 3,
|
||||
SPR_FLOOR_TEXTURE_MARTIAN = SPR_FLOOR_TEXTURE_GRASS + 4,
|
||||
SPR_FLOOR_TEXTURE_CHECKERBOARD = SPR_FLOOR_TEXTURE_GRASS + 5,
|
||||
SPR_FLOOR_TEXTURE_GRASS_CLUMPS = SPR_FLOOR_TEXTURE_GRASS + 6,
|
||||
SPR_FLOOR_TEXTURE_ICE = SPR_FLOOR_TEXTURE_GRASS + 7,
|
||||
SPR_FLOOR_TEXTURE_GRID_RED = SPR_FLOOR_TEXTURE_GRASS + 8,
|
||||
SPR_FLOOR_TEXTURE_GRID_YELLOW = SPR_FLOOR_TEXTURE_GRASS + 9,
|
||||
SPR_FLOOR_TEXTURE_GRID_BLUE = SPR_FLOOR_TEXTURE_GRASS + 10,
|
||||
SPR_FLOOR_TEXTURE_GRID_GREEN = SPR_FLOOR_TEXTURE_GRASS + 11,
|
||||
SPR_FLOOR_TEXTURE_SAND_DARK = SPR_FLOOR_TEXTURE_GRASS + 12,
|
||||
SPR_FLOOR_TEXTURE_SAND_LIGHT = SPR_FLOOR_TEXTURE_GRASS + 13,
|
||||
SPR_FLOOR_TEXTURE_GRASS = 5579,
|
||||
SPR_FLOOR_TEXTURE_SAND = SPR_FLOOR_TEXTURE_GRASS + 1,
|
||||
SPR_FLOOR_TEXTURE_DIRT = SPR_FLOOR_TEXTURE_GRASS + 2,
|
||||
SPR_FLOOR_TEXTURE_ROCK = SPR_FLOOR_TEXTURE_GRASS + 3,
|
||||
SPR_FLOOR_TEXTURE_MARTIAN = SPR_FLOOR_TEXTURE_GRASS + 4,
|
||||
SPR_FLOOR_TEXTURE_CHECKERBOARD = SPR_FLOOR_TEXTURE_GRASS + 5,
|
||||
SPR_FLOOR_TEXTURE_GRASS_CLUMPS = SPR_FLOOR_TEXTURE_GRASS + 6,
|
||||
SPR_FLOOR_TEXTURE_ICE = SPR_FLOOR_TEXTURE_GRASS + 7,
|
||||
SPR_FLOOR_TEXTURE_GRID_RED = SPR_FLOOR_TEXTURE_GRASS + 8,
|
||||
SPR_FLOOR_TEXTURE_GRID_YELLOW = SPR_FLOOR_TEXTURE_GRASS + 9,
|
||||
SPR_FLOOR_TEXTURE_GRID_BLUE = SPR_FLOOR_TEXTURE_GRASS + 10,
|
||||
SPR_FLOOR_TEXTURE_GRID_GREEN = SPR_FLOOR_TEXTURE_GRASS + 11,
|
||||
SPR_FLOOR_TEXTURE_SAND_DARK = SPR_FLOOR_TEXTURE_GRASS + 12,
|
||||
SPR_FLOOR_TEXTURE_SAND_LIGHT = SPR_FLOOR_TEXTURE_GRASS + 13,
|
||||
|
||||
SPR_WALL_TEXTURE_ROCK = 5593,
|
||||
SPR_WALL_TEXTURE_WOOD_RED = SPR_WALL_TEXTURE_ROCK + 1,
|
||||
SPR_WALL_TEXTURE_WOOD_BLACK = SPR_WALL_TEXTURE_ROCK + 2,
|
||||
SPR_WALL_TEXTURE_ICE = SPR_WALL_TEXTURE_ROCK + 3,
|
||||
SPR_WALL_TEXTURE_ROCK = 5593,
|
||||
SPR_WALL_TEXTURE_WOOD_RED = SPR_WALL_TEXTURE_ROCK + 1,
|
||||
SPR_WALL_TEXTURE_WOOD_BLACK = SPR_WALL_TEXTURE_ROCK + 2,
|
||||
SPR_WALL_TEXTURE_ICE = SPR_WALL_TEXTURE_ROCK + 3,
|
||||
|
||||
SPR_TOOLBAR_PAUSE = 5597,
|
||||
SPR_TOOLBAR_FILE = 5599,
|
||||
SPR_TOOLBAR_ZOOM_OUT = 5601,
|
||||
SPR_TOOLBAR_ZOOM_IN = 5604,
|
||||
SPR_TOOLBAR_ROTATE = 5607,
|
||||
SPR_TOOLBAR_LAND = 5609,
|
||||
SPR_TOOLBAR_MAP = 5611,
|
||||
SPR_TOOLBAR_GUESTS = 5613,
|
||||
SPR_TOOLBAR_SCENERY = 5615,
|
||||
SPR_TOOLBAR_WATER = 5617,
|
||||
SPR_TOOLBAR_RIDES = 5619,
|
||||
SPR_TOOLBAR_VIEW = 5621,
|
||||
SPR_TOOLBAR_FOOTPATH = 5623,
|
||||
SPR_TOOLBAR_STAFF = 5627,
|
||||
SPR_TOOLBAR_PARK = 5629,
|
||||
SPR_TOOLBAR_CONSTRUCT_RIDE = 5631,
|
||||
SPR_TOOLBAR_CLEAR_SCENERY = 5633,
|
||||
SPR_TOOLBAR_PAUSE = 5597,
|
||||
SPR_TOOLBAR_FILE = 5599,
|
||||
SPR_TOOLBAR_ZOOM_OUT = 5601,
|
||||
SPR_TOOLBAR_ZOOM_IN = 5604,
|
||||
SPR_TOOLBAR_ROTATE = 5607,
|
||||
SPR_TOOLBAR_LAND = 5609,
|
||||
SPR_TOOLBAR_MAP = 5611,
|
||||
SPR_TOOLBAR_GUESTS = 5613,
|
||||
SPR_TOOLBAR_SCENERY = 5615,
|
||||
SPR_TOOLBAR_WATER = 5617,
|
||||
SPR_TOOLBAR_RIDES = 5619,
|
||||
SPR_TOOLBAR_VIEW = 5621,
|
||||
SPR_TOOLBAR_FOOTPATH = 5623,
|
||||
SPR_TOOLBAR_STAFF = 5627,
|
||||
SPR_TOOLBAR_PARK = 5629,
|
||||
SPR_TOOLBAR_CONSTRUCT_RIDE = 5631,
|
||||
SPR_TOOLBAR_CLEAR_SCENERY = 5633,
|
||||
|
||||
SPR_NEXT_WEATHER = 23189,
|
||||
SPR_WEATHER_SUN = 23190,
|
||||
SPR_WEATHER_SUN_CLOUD = 23191,
|
||||
SPR_WEATHER_CLOUD = 23192,
|
||||
SPR_WEATHER_LIGHT_RAIN = 23193,
|
||||
SPR_WEATHER_HEAVY_RAIN = 23194,
|
||||
SPR_WEATHER_STORM = 23195,
|
||||
SPR_WEATHER_UNKNOWN = 23196,
|
||||
SPR_NEXT_WEATHER = 23189,
|
||||
SPR_WEATHER_SUN = 23190,
|
||||
SPR_WEATHER_SUN_CLOUD = 23191,
|
||||
SPR_WEATHER_CLOUD = 23192,
|
||||
SPR_WEATHER_LIGHT_RAIN = 23193,
|
||||
SPR_WEATHER_HEAVY_RAIN = 23194,
|
||||
SPR_WEATHER_STORM = 23195,
|
||||
SPR_WEATHER_UNKNOWN = 23196,
|
||||
|
||||
SPR_RATING_LOW = 23197,
|
||||
SPR_RATING_HIGH = 23198,
|
||||
SPR_RATING_LOW = 23197,
|
||||
SPR_RATING_HIGH = 23198,
|
||||
|
||||
SPR_MENU_NEW_GAME = 23207,
|
||||
SPR_MENU_LOAD_GAME = 23208,
|
||||
SPR_MENU_TUTORIAL = 23209,
|
||||
SPR_MENU_EXIT = 23210,
|
||||
SPR_MENU_TOOLBOX = 23211,
|
||||
SPR_MENU_LOGO = 23212,
|
||||
SPR_CREDITS_LOGO_SMALL = 23213,
|
||||
SPR_CREDITS_CHRIS_SAWYER_SMALL = 23214,
|
||||
SPR_INTRO_CHRIS_SAWYER_00 = 23215,
|
||||
SPR_INTRO_CHRIS_SAWYER_10 = SPR_INTRO_CHRIS_SAWYER_00 + 1,
|
||||
SPR_INTRO_LOGO_00 = 23218,
|
||||
SPR_INTRO_LOGO_10 = SPR_INTRO_LOGO_00 + 1,
|
||||
SPR_INTRO_LOGO_20 = SPR_INTRO_LOGO_00 + 2,
|
||||
SPR_INTRO_LOGO_01 = SPR_INTRO_LOGO_00 + 3,
|
||||
SPR_INTRO_LOGO_11 = SPR_INTRO_LOGO_00 + 4,
|
||||
SPR_INTRO_LOGO_21 = SPR_INTRO_LOGO_00 + 5,
|
||||
SPR_MENU_NEW_GAME = 23207,
|
||||
SPR_MENU_LOAD_GAME = 23208,
|
||||
SPR_MENU_TUTORIAL = 23209,
|
||||
SPR_MENU_EXIT = 23210,
|
||||
SPR_MENU_TOOLBOX = 23211,
|
||||
SPR_MENU_LOGO = 23212,
|
||||
SPR_CREDITS_LOGO_SMALL = 23213,
|
||||
SPR_CREDITS_CHRIS_SAWYER_SMALL = 23214,
|
||||
SPR_INTRO_CHRIS_SAWYER_00 = 23215,
|
||||
SPR_INTRO_CHRIS_SAWYER_10 = SPR_INTRO_CHRIS_SAWYER_00 + 1,
|
||||
SPR_INTRO_LOGO_00 = 23218,
|
||||
SPR_INTRO_LOGO_10 = SPR_INTRO_LOGO_00 + 1,
|
||||
SPR_INTRO_LOGO_20 = SPR_INTRO_LOGO_00 + 2,
|
||||
SPR_INTRO_LOGO_01 = SPR_INTRO_LOGO_00 + 3,
|
||||
SPR_INTRO_LOGO_11 = SPR_INTRO_LOGO_00 + 4,
|
||||
SPR_INTRO_LOGO_21 = SPR_INTRO_LOGO_00 + 5,
|
||||
|
||||
SPR_SIX_FLAGS = 23225,
|
||||
SPR_INTRO_INFOGRAMES_00 = 23226,
|
||||
SPR_INTRO_INFOGRAMES_10 = SPR_INTRO_INFOGRAMES_00 + 1,
|
||||
SPR_INTRO_INFOGRAMES_01 = SPR_INTRO_INFOGRAMES_00 + 2,
|
||||
SPR_INTRO_INFOGRAMES_11 = SPR_INTRO_INFOGRAMES_00 + 3,
|
||||
SPR_CREDITS_INFOGRAMES = 23230,
|
||||
SPR_SIX_FLAGS = 23225,
|
||||
SPR_INTRO_INFOGRAMES_00 = 23226,
|
||||
SPR_INTRO_INFOGRAMES_10 = SPR_INTRO_INFOGRAMES_00 + 1,
|
||||
SPR_INTRO_INFOGRAMES_01 = SPR_INTRO_INFOGRAMES_00 + 2,
|
||||
SPR_INTRO_INFOGRAMES_11 = SPR_INTRO_INFOGRAMES_00 + 3,
|
||||
SPR_CREDITS_INFOGRAMES = 23230,
|
||||
|
||||
SPR_G2_BEGIN = 324288,
|
||||
SPR_G2_LOGO = SPR_G2_BEGIN + 0,
|
||||
SPR_G2_TITLE = SPR_G2_BEGIN + 1,
|
||||
SPR_G2_FASTFORWARD = SPR_G2_BEGIN + 2,
|
||||
SPR_G2_SPEED_ARROW = SPR_G2_BEGIN + 3,
|
||||
SPR_G2_HYPER_ARROW = SPR_G2_BEGIN + 4
|
||||
SPR_G2_BEGIN = 324288,
|
||||
SPR_G2_LOGO = SPR_G2_BEGIN + 0,
|
||||
SPR_G2_TITLE = SPR_G2_BEGIN + 1,
|
||||
SPR_G2_FASTFORWARD = SPR_G2_BEGIN + 2,
|
||||
SPR_G2_SPEED_ARROW = SPR_G2_BEGIN + 3,
|
||||
SPR_G2_HYPER_ARROW = SPR_G2_BEGIN + 4,
|
||||
SPR_G2_TAB_TWITCH = SPR_G2_BEGIN + 5
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -46,6 +46,7 @@ enum {
|
|||
WINDOW_OPTIONS_PAGE_AUDIO,
|
||||
WINDOW_OPTIONS_PAGE_INPUT,
|
||||
WINDOW_OPTIONS_PAGE_MISC,
|
||||
WINDOW_OPTIONS_PAGE_TWITCH,
|
||||
WINDOW_OPTIONS_PAGE_COUNT
|
||||
};
|
||||
|
||||
|
@ -59,6 +60,7 @@ enum WINDOW_OPTIONS_WIDGET_IDX {
|
|||
WIDX_TAB_3,
|
||||
WIDX_TAB_4,
|
||||
WIDX_TAB_5,
|
||||
WIDX_TAB_6,
|
||||
|
||||
WIDX_RESOLUTION,
|
||||
WIDX_RESOLUTION_DROPDOWN,
|
||||
|
@ -104,6 +106,13 @@ enum WINDOW_OPTIONS_WIDGET_IDX {
|
|||
WIDX_ALLOW_SUBTYPE_SWITCHING,
|
||||
WIDX_DEBUGGING_TOOLS,
|
||||
WIDX_TEST_UNFINISHED_TRACKS,
|
||||
|
||||
WIDX_CHANNEL_BUTTON,
|
||||
WIDX_FOLLOWER_PEEP_NAMES_CHECKBOX,
|
||||
WIDX_FOLLOWER_PEEP_TRACKING_CHECKBOX,
|
||||
WIDX_CHAT_PEEP_NAMES_CHECKBOX,
|
||||
WIDX_CHAT_PEEP_TRACKING_CHECKBOX,
|
||||
WIDX_NEWS_CHECKBOX,
|
||||
WINDOW_OPTIONS_WIDGETS_SIZE // Marks the end of the widget list, leave as last item
|
||||
};
|
||||
|
||||
|
@ -120,6 +129,7 @@ static rct_widget window_options_widgets[] = {
|
|||
{ WWT_TAB, 1, 65, 95, 17, 43, 0x2000144E, STR_NONE },
|
||||
{ WWT_TAB, 1, 96, 126, 17, 43, 0x2000144E, STR_NONE },
|
||||
{ WWT_TAB, 1, 127, 157, 17, 43, 0x2000144E, STR_NONE },
|
||||
{ WWT_TAB, 1, 158, 188, 17, 43, 0x2000144E, STR_NONE },
|
||||
|
||||
// Display tab
|
||||
{ WWT_DROPDOWN, 0, 155, 299, 53, 64, 840, STR_NONE }, // resolution
|
||||
|
@ -170,11 +180,20 @@ static rct_widget window_options_widgets[] = {
|
|||
{ WWT_CHECKBOX, 2, 10, 299, 98, 109, 5122, STR_NONE }, // allow subtype
|
||||
{ WWT_CHECKBOX, 2, 10, 299, 113, 124, 5150, STR_NONE }, // enabled debugging tools
|
||||
{ WWT_CHECKBOX, 2, 10, 299, 128, 139, 5155, 5156 }, // test unfinished tracks
|
||||
|
||||
//Twitch tab
|
||||
{ WWT_DROPDOWN_BUTTON, 2, 10, 299, 53, 64, STR_TWITCH_NAME, STR_NONE }, // Twitch channel name
|
||||
{ WWT_CHECKBOX, 2, 10, 299, 68, 79, STR_TWITCH_PEEP_FOLLOWERS, STR_TWITCH_PEEP_FOLLOWERS_TIP }, // Twitch name peeps by follows
|
||||
{ WWT_CHECKBOX, 2, 10, 299, 83, 94, STR_TWITCH_FOLLOWERS_TRACK, STR_TWITCH_FOLLOWERS_TRACK_TIP}, // Twitch information on for follows
|
||||
{ WWT_CHECKBOX, 2, 10, 299, 98, 109, STR_TWITCH_PEEP_CHAT, STR_TWITCH_PEEP_CHAT_TIP }, // Twitch name peeps by chat
|
||||
{ WWT_CHECKBOX, 2, 10, 299, 113, 124, STR_TWITCH_CHAT_TRACK, STR_TWITCH_CHAT_TRACK_TIP }, // Twitch information on for chat
|
||||
{ WWT_CHECKBOX, 2, 10, 299, 128, 139, STR_TWITCH_CHAT_NEWS, STR_TWITCH_CHAT_NEWS_TIP }, // Twitch chat !news as notifications in game
|
||||
|
||||
{ WIDGETS_END },
|
||||
};
|
||||
|
||||
const int window_options_tab_animation_divisor[] = { 4, 8, 2, 2, 2 };
|
||||
const int window_options_tab_animation_frames[] = { 16, 8, 16, 4, 16 };
|
||||
const int window_options_tab_animation_divisor[] = { 4, 8, 2, 2, 2, 1 };
|
||||
const int window_options_tab_animation_frames[] = { 16, 8, 16, 4, 16, 1 };
|
||||
|
||||
static void window_options_set_page(rct_window *w, int page);
|
||||
static void window_options_set_pressed_tab(rct_window *w);
|
||||
|
@ -188,6 +207,7 @@ static void window_options_dropdown();
|
|||
static void window_options_update(rct_window *w);
|
||||
static void window_options_invalidate();
|
||||
static void window_options_paint();
|
||||
static void window_options_text_input();
|
||||
static void window_options_show_dropdown(rct_window *w, rct_widget *widget, int num_items);
|
||||
static void window_options_update_height_markers();
|
||||
|
||||
|
@ -211,7 +231,7 @@ static void* window_options_events[] = {
|
|||
window_options_emptysub,
|
||||
window_options_emptysub,
|
||||
window_options_emptysub,
|
||||
window_options_emptysub,
|
||||
window_options_text_input,
|
||||
window_options_emptysub,
|
||||
window_options_emptysub,
|
||||
window_options_emptysub,
|
||||
|
@ -244,6 +264,7 @@ void window_options_open()
|
|||
(1ULL << WIDX_TAB_3) |
|
||||
(1ULL << WIDX_TAB_4) |
|
||||
(1ULL << WIDX_TAB_5) |
|
||||
(1ULL << WIDX_TAB_6) |
|
||||
(1ULL << WIDX_SOUND) |
|
||||
(1ULL << WIDX_SOUND_DROPDOWN) |
|
||||
(1ULL << WIDX_SOUND_CHECKBOX) |
|
||||
|
@ -283,7 +304,13 @@ void window_options_open()
|
|||
(1ULL << WIDX_TEST_UNFINISHED_TRACKS) |
|
||||
(1ULL << WIDX_RCT1_COLOUR_SCHEME) |
|
||||
(1ULL << WIDX_DATE_FORMAT) |
|
||||
(1ULL << WIDX_DATE_FORMAT_DROPDOWN);
|
||||
(1ULL << WIDX_DATE_FORMAT_DROPDOWN) |
|
||||
(1ULL << WIDX_CHANNEL_BUTTON) |
|
||||
(1ULL << WIDX_FOLLOWER_PEEP_NAMES_CHECKBOX) |
|
||||
(1ULL << WIDX_FOLLOWER_PEEP_TRACKING_CHECKBOX) |
|
||||
(1ULL << WIDX_CHAT_PEEP_NAMES_CHECKBOX) |
|
||||
(1ULL << WIDX_CHAT_PEEP_TRACKING_CHECKBOX) |
|
||||
(1ULL << WIDX_NEWS_CHECKBOX);
|
||||
|
||||
w->page = WINDOW_OPTIONS_PAGE_DISPLAY;
|
||||
window_init_scroll_widgets(w);
|
||||
|
@ -312,11 +339,15 @@ static void window_options_mouseup()
|
|||
case WIDX_TAB_3:
|
||||
case WIDX_TAB_4:
|
||||
case WIDX_TAB_5:
|
||||
case WIDX_TAB_6:
|
||||
window_options_set_page(w, widgetIndex - WIDX_TAB_1);
|
||||
break;
|
||||
case WIDX_HOTKEY_DROPDOWN:
|
||||
window_shortcut_keys_open();
|
||||
break;
|
||||
case WIDX_CHANNEL_BUTTON:
|
||||
window_text_input_raw_open(w, widgetIndex, STR_TWITCH_NAME, STR_TWITCH_NAME_DESC, gConfigTwitch.channel, 32);
|
||||
break;
|
||||
case WIDX_SCREEN_EDGE_SCROLLING:
|
||||
gConfigGeneral.edge_scrolling ^= 1;
|
||||
config_save_default();
|
||||
|
@ -387,6 +418,31 @@ static void window_options_mouseup()
|
|||
config_save_default();
|
||||
window_invalidate(w);
|
||||
break;
|
||||
case WIDX_FOLLOWER_PEEP_NAMES_CHECKBOX:
|
||||
gConfigTwitch.enable_follower_peep_names ^= 1;
|
||||
config_save_default();
|
||||
window_invalidate(w);
|
||||
break;
|
||||
case WIDX_FOLLOWER_PEEP_TRACKING_CHECKBOX:
|
||||
gConfigTwitch.enable_follower_peep_tracking ^= 1;
|
||||
config_save_default();
|
||||
window_invalidate(w);
|
||||
break;
|
||||
case WIDX_CHAT_PEEP_NAMES_CHECKBOX:
|
||||
gConfigTwitch.enable_chat_peep_names ^= 1;
|
||||
config_save_default();
|
||||
window_invalidate(w);
|
||||
break;
|
||||
case WIDX_CHAT_PEEP_TRACKING_CHECKBOX:
|
||||
gConfigTwitch.enable_chat_peep_tracking ^= 1;
|
||||
config_save_default();
|
||||
window_invalidate(w);
|
||||
break;
|
||||
case WIDX_NEWS_CHECKBOX:
|
||||
gConfigTwitch.enable_news ^= 1;
|
||||
config_save_default();
|
||||
window_invalidate(w);
|
||||
break;
|
||||
case WIDX_SAVE_PLUGIN_DATA_CHECKBOX:
|
||||
gConfigGeneral.save_plugin_data ^= 1;
|
||||
config_save_default();
|
||||
|
@ -867,6 +923,21 @@ static void window_options_invalidate()
|
|||
window_options_widgets[WIDX_ALLOW_SUBTYPE_SWITCHING].type = WWT_CHECKBOX;
|
||||
window_options_widgets[WIDX_DEBUGGING_TOOLS].type = WWT_CHECKBOX;
|
||||
window_options_widgets[WIDX_TEST_UNFINISHED_TRACKS].type = WWT_CHECKBOX;
|
||||
break;
|
||||
case WINDOW_OPTIONS_PAGE_TWITCH:
|
||||
widget_set_checkbox_value(w, WIDX_FOLLOWER_PEEP_NAMES_CHECKBOX, gConfigTwitch.enable_follower_peep_names);
|
||||
widget_set_checkbox_value(w, WIDX_FOLLOWER_PEEP_TRACKING_CHECKBOX, gConfigTwitch.enable_follower_peep_tracking);
|
||||
widget_set_checkbox_value(w, WIDX_CHAT_PEEP_NAMES_CHECKBOX, gConfigTwitch.enable_chat_peep_names);
|
||||
widget_set_checkbox_value(w, WIDX_CHAT_PEEP_TRACKING_CHECKBOX, gConfigTwitch.enable_chat_peep_tracking);
|
||||
widget_set_checkbox_value(w, WIDX_NEWS_CHECKBOX, gConfigTwitch.enable_news);
|
||||
|
||||
window_options_widgets[WIDX_CHANNEL_BUTTON].type = WWT_DROPDOWN_BUTTON;
|
||||
window_options_widgets[WIDX_FOLLOWER_PEEP_NAMES_CHECKBOX].type = WWT_CHECKBOX;
|
||||
window_options_widgets[WIDX_FOLLOWER_PEEP_TRACKING_CHECKBOX].type = WWT_CHECKBOX;
|
||||
window_options_widgets[WIDX_CHAT_PEEP_NAMES_CHECKBOX].type = WWT_CHECKBOX;
|
||||
window_options_widgets[WIDX_CHAT_PEEP_TRACKING_CHECKBOX].type = WWT_CHECKBOX;
|
||||
window_options_widgets[WIDX_NEWS_CHECKBOX].type = WWT_CHECKBOX;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -973,6 +1044,26 @@ static void window_options_update_height_markers()
|
|||
gfx_invalidate_screen();
|
||||
}
|
||||
|
||||
static void window_options_text_input(){
|
||||
short widgetIndex;
|
||||
rct_window *w;
|
||||
char _cl;
|
||||
char* text;
|
||||
|
||||
window_text_input_get_registers(w, widgetIndex, _cl, text);
|
||||
if (_cl == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (widgetIndex == WIDX_CHANNEL_BUTTON){
|
||||
if (gConfigTwitch.channel != NULL)
|
||||
free(gConfigTwitch.channel);
|
||||
gConfigTwitch.channel = _strdup(text);
|
||||
config_save_default();
|
||||
}
|
||||
}
|
||||
|
||||
#pragma region Common
|
||||
|
||||
static void window_options_set_page(rct_window *w, int page)
|
||||
|
@ -1016,6 +1107,7 @@ static void window_options_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w
|
|||
window_options_draw_tab_image(dpi, w, WINDOW_OPTIONS_PAGE_AUDIO, 5335);
|
||||
window_options_draw_tab_image(dpi, w, WINDOW_OPTIONS_PAGE_INPUT, 5201);
|
||||
window_options_draw_tab_image(dpi, w, WINDOW_OPTIONS_PAGE_MISC, 5205);
|
||||
window_options_draw_tab_image(dpi, w, WINDOW_OPTIONS_PAGE_TWITCH, SPR_G2_TAB_TWITCH);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
|
|
@ -161,6 +161,67 @@ void window_text_input_open(rct_window* call_w, int call_widget, rct_string_id t
|
|||
w->colours[2] = call_w->colours[2];
|
||||
}
|
||||
|
||||
void window_text_input_raw_open(rct_window* call_w, int call_widget, rct_string_id title, rct_string_id description, utf8string existing_text, int maxLength)
|
||||
{
|
||||
_maxInputLength = maxLength;
|
||||
|
||||
window_close_by_class(WC_TEXTINPUT);
|
||||
|
||||
// Clear the text input buffer
|
||||
memset(text_input, 0, maxLength);
|
||||
|
||||
// Enter in the the text input buffer any existing
|
||||
// text.
|
||||
if (existing_text != NULL)
|
||||
strncpy(text_input, existing_text, maxLength);
|
||||
|
||||
// In order to prevent strings that exceed the maxLength
|
||||
// from crashing the game.
|
||||
text_input[maxLength - 1] = '\0';
|
||||
|
||||
// This is the text displayed above the input box
|
||||
input_text_description = description;
|
||||
|
||||
// Work out the existing size of the window
|
||||
char wrapped_string[512];
|
||||
strcpy(wrapped_string, text_input);
|
||||
|
||||
int no_lines = 0, font_height = 0;
|
||||
|
||||
// String length needs to add 12 either side of box
|
||||
// +13 for cursor when max length.
|
||||
gfx_wrap_string(wrapped_string, WW - (24 + 13), &no_lines, &font_height);
|
||||
|
||||
int height = no_lines * 10 + WH;
|
||||
|
||||
// Window will be in the center of the screen
|
||||
rct_window* w = window_create_centred(
|
||||
WW,
|
||||
height,
|
||||
(uint32*)window_text_input_events,
|
||||
WC_TEXTINPUT,
|
||||
WF_STICK_TO_FRONT
|
||||
);
|
||||
|
||||
w->widgets = window_text_input_widgets;
|
||||
w->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_CANCEL) | (1 << WIDX_OKAY);
|
||||
|
||||
window_text_input_widgets[WIDX_TITLE].image = title;
|
||||
|
||||
// Save calling window details so that the information
|
||||
// can be passed back to the correct window & widget
|
||||
calling_class = call_w->classification;
|
||||
calling_number = call_w->number;
|
||||
calling_widget = call_widget;
|
||||
|
||||
platform_start_text_input(text_input, maxLength);
|
||||
|
||||
window_init_scroll_widgets(w);
|
||||
w->colours[0] = call_w->colours[0];
|
||||
w->colours[1] = call_w->colours[1];
|
||||
w->colours[2] = call_w->colours[2];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "../interface/window.h"
|
||||
#include "../interface/viewport.h"
|
||||
#include "../localisation/localisation.h"
|
||||
#include "../network/twitch.h"
|
||||
#include "../scenario.h"
|
||||
#include "../world/scenery.h"
|
||||
#include "../world/banner.h"
|
||||
|
@ -65,11 +66,15 @@ enum {
|
|||
typedef enum {
|
||||
DDIDX_LOAD_GAME = 0,
|
||||
DDIDX_SAVE_GAME = 1,
|
||||
// seperator
|
||||
DDIDX_ABOUT = 3,
|
||||
DDIDX_OPTIONS = 4,
|
||||
DDIDX_SCREENSHOT = 5,
|
||||
// seperator
|
||||
DDIDX_QUIT_TO_MENU = 7,
|
||||
DDIDX_EXIT_OPENRCT2 = 8,
|
||||
// seperator
|
||||
DDIDX_ENABLE_TWITCH = 10
|
||||
} FILE_MENU_DDIDX;
|
||||
|
||||
typedef enum {
|
||||
|
@ -204,6 +209,8 @@ void toggle_land_window(rct_window *topToolbar, int widgetIndex);
|
|||
void toggle_clear_scenery_window(rct_window *topToolbar, int widgetIndex);
|
||||
void toggle_water_window(rct_window *topToolbar, int widgetIndex);
|
||||
|
||||
static bool _menuDropdownIncludesTwitch;
|
||||
|
||||
/**
|
||||
* Creates the main game top toolbar window.
|
||||
* rct2: 0x0066B485 (part of 0x0066B3E8)
|
||||
|
@ -306,6 +313,7 @@ static void window_top_toolbar_mousedown(int widgetIndex, rct_window*w, rct_widg
|
|||
|
||||
switch (widgetIndex) {
|
||||
case WIDX_FILE_MENU:
|
||||
_menuDropdownIncludesTwitch = false;
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)) {
|
||||
gDropdownItemsFormat[0] = STR_ABOUT;
|
||||
gDropdownItemsFormat[1] = STR_OPTIONS;
|
||||
|
@ -340,6 +348,16 @@ static void window_top_toolbar_mousedown(int widgetIndex, rct_window*w, rct_widg
|
|||
gDropdownItemsFormat[7] = STR_QUIT_TO_MENU;
|
||||
gDropdownItemsFormat[8] = STR_EXIT_OPENRCT2;
|
||||
numItems = 9;
|
||||
|
||||
#ifndef DISABLE_TWITCH
|
||||
if (gConfigTwitch.channel != NULL && gConfigTwitch.channel[0] != 0) {
|
||||
_menuDropdownIncludesTwitch = true;
|
||||
gDropdownItemsFormat[9] = 0;
|
||||
gDropdownItemsFormat[10] = 1156;
|
||||
gDropdownItemsArgs[10] = STR_TWITCH_ENABLE;
|
||||
numItems = 11;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
window_dropdown_show_text(
|
||||
w->x + widget->left,
|
||||
|
@ -349,6 +367,9 @@ static void window_top_toolbar_mousedown(int widgetIndex, rct_window*w, rct_widg
|
|||
DROPDOWN_FLAG_STAY_OPEN,
|
||||
numItems
|
||||
);
|
||||
|
||||
if (_menuDropdownIncludesTwitch && gTwitchEnable)
|
||||
gDropdownItemsChecked |= (1 << 10);
|
||||
break;
|
||||
case WIDX_VIEW_MENU:
|
||||
top_toolbar_init_view_menu(w, widget);
|
||||
|
@ -425,6 +446,9 @@ static void window_top_toolbar_dropdown()
|
|||
case DDIDX_EXIT_OPENRCT2:
|
||||
rct2_quit();
|
||||
break;
|
||||
case DDIDX_ENABLE_TWITCH:
|
||||
gTwitchEnable = !gTwitchEnable;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WIDX_VIEW_MENU:
|
||||
|
|
Loading…
Reference in New Issue