Mercurial > mm7
changeset 2054:62a27b2cfcc2
Player.swig
author | Nomad |
---|---|
date | Sat, 30 Nov 2013 21:00:37 +0200 |
parents | 64e23bf9d27e |
children | b7485a6502f2 |
files | Build/Visual Studio 2012/World of Might and Magic.vcxproj Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters LuaVM.h NewUI/Core/UIControl.h Player.cpp Player.h Player.swig Player_wrap.cxx lib/swig.bat mm7_data.cpp mm7_data.h |
diffstat | 10 files changed, 83 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
--- a/Build/Visual Studio 2012/World of Might and Magic.vcxproj Fri Nov 29 12:20:44 2013 +0200 +++ b/Build/Visual Studio 2012/World of Might and Magic.vcxproj Sat Nov 30 21:00:37 2013 +0200 @@ -166,6 +166,7 @@ <ClCompile Include="..\..\LightsStack.cpp" /> <ClCompile Include="..\..\LOD.cpp" /> <ClCompile Include="..\..\Log.cpp" /> + <ClCompile Include="..\..\LuaVM.cpp" /> <ClCompile Include="..\..\mm7text_ru.cpp" /> <ClCompile Include="..\..\mm7_2.cpp" /> <ClCompile Include="..\..\mm7_3.cpp" /> @@ -188,6 +189,7 @@ <ClCompile Include="..\..\ParticleEngine.cpp" /> <ClCompile Include="..\..\Party.cpp" /> <ClCompile Include="..\..\Player.cpp" /> + <ClCompile Include="..\..\Player_wrap.cxx" /> <ClCompile Include="..\..\Random.cpp" /> <ClCompile Include="..\..\Render.cpp" /> <ClCompile Include="..\..\SaveLoad.cpp" /> @@ -226,7 +228,6 @@ <ClCompile Include="..\..\Vis.cpp" /> <ClCompile Include="..\..\Weather.cpp" /> <ClCompile Include="..\..\_deleted.cpp" /> - <ClCompile Include="LuaVM.cpp" /> </ItemGroup> <ItemGroup> <ClInclude Include="..\..\Actor.h" /> @@ -386,8 +387,15 @@ <FileType>Document</FileType> <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">call "../../lib/swig" "%(FileName)" %(RelativeDir) "%(FileName)%(Extension)" "%(FullPath)" "$(SolutionDir)" %(Filename)_wrap.cxx</Command> <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename)_wrap.cxx</Outputs> + <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).swig</Message> </CustomBuild> <None Include="..\..\lib\swig.bat" /> + <CustomBuild Include="..\..\Player.swig"> + <FileType>Document</FileType> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">call "../../lib/swig" "%(FileName)" %(RelativeDir) "%(FileName)%(Extension)" "%(FullPath)" "$(SolutionDir)" %(Filename)_wrap.cxx</Command> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename)_wrap.cxx</Outputs> + <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).swig</Message> + </CustomBuild> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets">
--- a/Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters Fri Nov 29 12:20:44 2013 +0200 +++ b/Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters Sat Nov 30 21:00:37 2013 +0200 @@ -308,7 +308,8 @@ <Filter>NewUI\Core</Filter> </ClCompile> <ClCompile Include="..\..\Timer.cpp" /> - <ClCompile Include="LuaVM.cpp" /> + <ClCompile Include="..\..\LuaVM.cpp" /> + <ClCompile Include="..\..\Player_wrap.cxx" /> </ItemGroup> <ItemGroup> <ClInclude Include="..\..\Level\Decoration.h"> @@ -608,5 +609,6 @@ <CustomBuild Include="..\..\NewUI\Core\UIControlModule.swig"> <Filter>NewUI\Core</Filter> </CustomBuild> + <CustomBuild Include="..\..\Player.swig" /> </ItemGroup> </Project> \ No newline at end of file
--- a/LuaVM.h Fri Nov 29 12:20:44 2013 +0200 +++ b/LuaVM.h Sat Nov 30 21:00:37 2013 +0200 @@ -3,6 +3,8 @@ class LuaVM { public: + inline LuaVM(): L(nullptr) {} + void Initialize(); bool DoFile(const char *filename);
--- a/NewUI/Core/UIControl.h Fri Nov 29 12:20:44 2013 +0200 +++ b/NewUI/Core/UIControl.h Sat Nov 30 21:00:37 2013 +0200 @@ -10,45 +10,11 @@ virtual bool Focused() = 0; // Events - virtual bool OnKey(int key) - { - for (auto i = children.begin(); i != children.end(); ++i) - if ((*i)->OnKey(key)) - return true; - return false; - } - - virtual bool OnMouseLeftClick(int x, int y) - { - for (auto i = children.begin(); i != children.end(); ++i) - if ((*i)->OnMouseLeftClick(x, y)) - return true; - return false; - } - - virtual bool OnMouseRightClick(int x, int y) - { - for (auto i = children.begin(); i != children.end(); ++i) - if ((*i)->OnMouseRightClick(x, y)) - return true; - return false; - } - - virtual bool OnMouseEnter() - { - for (auto i = children.begin(); i != children.end(); ++i) - if ((*i)->OnMouseEnter()) - return true; - return false; - } - - virtual bool OnMouseLeave() - { - for (auto i = children.begin(); i != children.end(); ++i) - if ((*i)->OnMouseLeave()) - return true; - return false; - } + virtual bool OnKey(int key) {return DefaultOnKey(key);} + virtual bool OnMouseLeftClick(int x, int y) {return DefaultOnMouseLeftClick(x, y);} + virtual bool OnMouseRightClick(int x, int y) {return DefaultOnMouseRightClick(x, y);} + virtual bool OnMouseEnter() {return DefaultOnMouseEnter();} + virtual bool OnMouseLeave() {return DefaultOnMouseLeave();} // Container virtual bool AddControl(UIControl *ctrl) @@ -56,6 +22,7 @@ if (std::find(children.begin(), children.end(), ctrl) == children.end()) { children.push_back(ctrl); + ctrl->parent = this; return true; } return false; @@ -67,10 +34,55 @@ children.remove(ctrl); if (i != children.end()) + { + ctrl->parent = nullptr; return true; + } return false; } protected: - std::list<UIControl *> children; + UIControl *parent; + std::list<UIControl *> children; + + + bool DefaultOnKey(int key) + { + for (auto i = children.begin(); i != children.end(); ++i) + if ((*i)->OnKey(key)) + return true; + return false; + } + + bool DefaultOnMouseLeftClick(int x, int y) + { + for (auto i = children.begin(); i != children.end(); ++i) + if ((*i)->OnMouseLeftClick(x, y)) + return true; + return false; + } + + bool DefaultOnMouseRightClick(int x, int y) + { + for (auto i = children.begin(); i != children.end(); ++i) + if ((*i)->OnMouseRightClick(x, y)) + return true; + return false; + } + + bool DefaultOnMouseEnter() + { + for (auto i = children.begin(); i != children.end(); ++i) + if ((*i)->OnMouseEnter()) + return true; + return false; + } + + bool DefaultOnMouseLeave() + { + for (auto i = children.begin(); i != children.end(); ++i) + if ((*i)->OnMouseLeave()) + return true; + return false; + } }; \ No newline at end of file
--- a/Player.cpp Fri Nov 29 12:20:44 2013 +0200 +++ b/Player.cpp Sat Nov 30 21:00:37 2013 +0200 @@ -34,6 +34,9 @@ +NZIArray<struct Player *, 5> pPlayers; + + /* 381 */ #pragma pack(push, 1) struct PlayerCreation_AttributeProps
--- a/Player.h Fri Nov 29 12:20:44 2013 +0200 +++ b/Player.h Sat Nov 30 21:00:37 2013 +0200 @@ -840,3 +840,5 @@ char field_1B3B; }; #pragma pack(pop) + +extern NZIArray<struct Player *, 5> pPlayers; \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Player.swig Sat Nov 30 21:00:37 2013 +0200 @@ -0,0 +1,6 @@ +%module Player +%{ + #include "Player.h" +%} + +%include "../../../Player.h" \ No newline at end of file
--- a/lib/swig.bat Fri Nov 29 12:20:44 2013 +0200 +++ b/lib/swig.bat Sat Nov 30 21:00:37 2013 +0200 @@ -1,4 +1,3 @@ -@echo off rem echo 1 %1 rem echo 2 %2 rem echo 3 %3 @@ -6,6 +5,8 @@ rem echo 5 %5 rem echo 6 %6 +set WOMM_SWIG_SOLUTION_DIR=%CD% + rem echo xcopy %4 "../../lib/swig/swigwin-2.0.11" /y xcopy %4 "../../lib/swig/swigwin-2.0.11" /y @@ -13,4 +14,7 @@ swig -c++ -lua %3 rem echo xcopy "%6" %5"%2" /y -xcopy "%6" %5"%2" /y \ No newline at end of file +xcopy "%6" %5"%2" /y + +rem echo chdir /d %WOMM_SWIG_SOLUTION_DIR% +chdir /d %WOMM_SWIG_SOLUTION_DIR% \ No newline at end of file
--- a/mm7_data.cpp Fri Nov 29 12:20:44 2013 +0200 +++ b/mm7_data.cpp Sat Nov 30 21:00:37 2013 +0200 @@ -1305,7 +1305,6 @@ struct Texture *pTexture_PlayerFaceEradicated; struct Texture *pTexture_PlayerFaceDead; std::array< std::array<struct Texture *, 56>, 4> pTextures_PlayerFaces; -NZIArray<struct Player *, 5> pPlayers; __int64 qword_A750D8; // weak enum PlayerSpeech PlayerSpeechID; int uSpeakingCharacter; // weak
--- a/mm7_data.h Fri Nov 29 12:20:44 2013 +0200 +++ b/mm7_data.h Sat Nov 30 21:00:37 2013 +0200 @@ -963,7 +963,6 @@ extern struct Texture *pTexture_PlayerFaceDead; extern std::array< std::array<struct Texture *, 56>, 4> pTextures_PlayerFaces; extern int dword_A75070; // weak -extern NZIArray<struct Player *, 5> pPlayers; extern __int64 qword_A750D8; // weak extern enum PlayerSpeech PlayerSpeechID; extern int uSpeakingCharacter; // weak