Skip to content

Commit

Permalink
Migrate (frozen) guichan to guisan
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarod42 committed Oct 14, 2024
1 parent 90b3e15 commit 9ea5095
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 31 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ include(CheckTypeSize)
include(CheckFunctionExists)
include(CheckSymbolExists)

vendored_guichan()
vendored_guisan()

# Windows RC compiler definitions

Expand Down Expand Up @@ -1114,7 +1114,7 @@ if (ENABLE_STDIO_REDIRECT)
else ()
add_executable(stratagus src/stratagus/main.cpp)
endif ()
target_link_libraries(stratagus_lib PUBLIC ${stratagus_LIBS} ${CMAKE_DL_LIBS} guichan_lib)
target_link_libraries(stratagus_lib PUBLIC ${stratagus_LIBS} ${CMAKE_DL_LIBS} guisan_lib)
target_link_libraries(stratagus PUBLIC stratagus_lib)

target_include_directories(stratagus_lib SYSTEM PRIVATE third-party/mdns third-party/spiritless_po/include)
Expand Down
2 changes: 1 addition & 1 deletion src/editor/editloop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#include "video.h"
#include "widgets.h"

#include <guichan.hpp>
#include <guisan.hpp>

extern void DoScrollArea(int state, bool fast, bool isKeyboard);
extern void DrawGuichanWidgets();
Expand Down
4 changes: 2 additions & 2 deletions src/include/font.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

#include <SDL.h>
#include <array>
#include <guichan/font.hpp>
#include <guisan/font.hpp>
#include <string>
#include <utility>

Expand Down Expand Up @@ -92,7 +92,7 @@ class CFont : public gcn::Font

int getHeight() const override { return Height(); }
int getWidth(const std::string &text) const override { return Width(text); }
void drawString(gcn::Graphics *graphics, const std::string &text, int x, int y) override;
void drawString(gcn::Graphics *graphics, const std::string &text, int x, int y, bool enabled) override;
int getStringIndexAt(const std::string &text, int x) const override;

// Set to false to reverse color when drawing string
Expand Down
4 changes: 2 additions & 2 deletions src/include/movie.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
//@{

#include <SDL.h>
#include <guichan.hpp>
#include <guichan/sdl/sdlimage.hpp>
#include <guisan.hpp>
#include <guisan/sdl/sdlimage.hpp>

#ifdef USE_VORBIS

Expand Down
4 changes: 2 additions & 2 deletions src/include/video.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
#include "vec2i.h"

#include <SDL.h>
#include <guichan.hpp>
#include <guichan/sdl/sdlimage.hpp>
#include <guisan.hpp>
#include <guisan/sdl/sdlimage.hpp>
#include <memory>
#include <string_view>
#include <vector>
Expand Down
8 changes: 4 additions & 4 deletions src/include/widgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
#include "luacallback.h"

#include <functional>
#include <guichan.hpp>
#include <guichan/sdl.hpp>
#include <guichan/keylistener.hpp>
#include <guichan/mouselistener.hpp>
#include <guisan.hpp>
#include <guisan/sdl.hpp>
#include <guisan/keylistener.hpp>
#include <guisan/mouselistener.hpp>

extern bool GuichanActive;

Expand Down
3 changes: 1 addition & 2 deletions src/stratagus/mainloop.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// _________ __ __
// _________ __ __
// / _____// |_____________ _/ |______ ____ __ __ ______
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
Expand Down Expand Up @@ -58,7 +58,6 @@
# include <coz.h>
#endif

#include <guichan.hpp>
void DrawGuichanWidgets();


Expand Down
2 changes: 1 addition & 1 deletion src/stratagus/stratagus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ extern void beos_init(int argc, char **argv);
#include "missile.h" //for FreeBurningBuildingFrames

#include <SDL.h>
#include <guichan.hpp>
#include <guisan.hpp>
#include <string_view>

#ifdef USE_STACKTRACE
Expand Down
4 changes: 2 additions & 2 deletions src/ui/botpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
#include "video.h"

#include <cctype>
#include <guichan/key.hpp>
#include <guichan/sdl/sdlinput.hpp>
#include <guisan/key.hpp>
#include <guisan/sdl/sdlinput.hpp>
#include <vector>
#include <sstream>

Expand Down
2 changes: 1 addition & 1 deletion src/ui/mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
#include "widgets.h"

#include <cctype>
#include <guichan/actionevent.hpp>
#include <guisan/actionevent.hpp>
#include <stdexcept>

/*----------------------------------------------------------------------------
Expand Down
7 changes: 2 additions & 5 deletions src/ui/widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#include "sound.h"
#include "util.h"

#include <guichan/text.hpp>
#include <guisan/text.hpp>

/*----------------------------------------------------------------------------
-- Variables
Expand Down Expand Up @@ -171,8 +171,6 @@ static void MenuHandleKeyRepeat(unsigned key, unsigned keychar)
HandleKeyModifiersDown(key, keychar);
}

sdl2::RendererPtr guichanRenderer;

/**
** Initializes the GUI stuff
*/
Expand All @@ -183,8 +181,7 @@ void initGuichan()
// Set the target for the graphics object to be the screen.
// In other words, we will draw to the screen.
// Note, any surface will do, it doesn't have to be the screen.
guichanRenderer.reset(SDL_CreateSoftwareRenderer(TheScreen));
graphics->setTarget(guichanRenderer.get(), Video.Width, Video.Height);
graphics->setTarget(TheScreen);

Input = std::make_unique<gcn::SDLInput>();

Expand Down
6 changes: 3 additions & 3 deletions src/video/font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include "intern_video.h"
#include "video.h"

#include <guichan/sdl/sdlinput.hpp>
#include <guisan/sdl/sdlinput.hpp>
#include <map>
#include <vector>

Expand Down Expand Up @@ -141,7 +141,7 @@ int CFont::getStringIndexAt(const std::string &text, int x) const /* override */
}

void CFont::drawString(
gcn::Graphics *graphics, const std::string &txt, int x, int y) /* override */
gcn::Graphics *graphics, const std::string &txt, int x, int y, bool /*enabled*/) /* override */
{
DynamicLoad();
const gcn::ClipRectangle &r = graphics->getCurrentClipArea();
Expand Down Expand Up @@ -515,7 +515,7 @@ int convertSDLKeyCharacterToGuichanKey(int key)
event.type = SDL_KEYDOWN;
event.key.keysym.sym = (SDL_Keycode) key;
auto ret = input.convertSDLEventToGuichanKeyValue(event);
return ret == -1 ? key : ret;
return ret.getValue() == -1 ? key : ret.getValue();
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/video/video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,7 @@ bool CVideo::ResizeScreen(int w, int h)

if (Gui) {
if (auto graphics = dynamic_cast<gcn::SDLGraphics *>(Gui->getGraphics())) {
extern sdl2::RendererPtr guichanRenderer;
guichanRenderer.reset(SDL_CreateSoftwareRenderer(TheScreen));
graphics->setTarget(guichanRenderer.get(), w, h);
graphics->setTarget(TheScreen);
}
}

Expand Down
2 changes: 1 addition & 1 deletion third-party
Submodule third-party updated 205 files

0 comments on commit 9ea5095

Please sign in to comment.