mirror of
https://github.com/LIV2/amiberry.git
synced 2025-12-06 06:32:45 +00:00
Revert "refactor: use unique_ptr in some GUI elements"
This reverts commit e25d90651009ddf6ec15ef5604fa5b2902db0c08.
This commit is contained in:
parent
8196671d57
commit
1e2edb3c49
@ -1985,7 +1985,7 @@ void apply_theme()
|
|||||||
// Check if the font_name contains the full path to the file (e.g. in /usr/share/fonts)
|
// Check if the font_name contains the full path to the file (e.g. in /usr/share/fonts)
|
||||||
if (my_existsfile2(gui_theme.font_name.c_str()))
|
if (my_existsfile2(gui_theme.font_name.c_str()))
|
||||||
{
|
{
|
||||||
gui_font = std::make_unique<gcn::SDLTrueTypeFont>(gui_theme.font_name, gui_theme.font_size);
|
gui_font = new gcn::SDLTrueTypeFont(gui_theme.font_name, gui_theme.font_size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1993,7 +1993,7 @@ void apply_theme()
|
|||||||
std::string font = get_data_path();
|
std::string font = get_data_path();
|
||||||
font.append(gui_theme.font_name);
|
font.append(gui_theme.font_name);
|
||||||
if (my_existsfile2(font.c_str()))
|
if (my_existsfile2(font.c_str()))
|
||||||
gui_font = std::make_unique<gcn::SDLTrueTypeFont>(font, gui_theme.font_size);
|
gui_font = new gcn::SDLTrueTypeFont(font, gui_theme.font_size);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If the font file was not found in the data directory, fallback to a system font
|
// If the font file was not found in the data directory, fallback to a system font
|
||||||
@ -2019,7 +2019,7 @@ void apply_theme()
|
|||||||
write_log("An error occurred while trying to open the GUI font! Exception: %s\n", ex.what());
|
write_log("An error occurred while trying to open the GUI font! Exception: %s\n", ex.what());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
gcn::Widget::setGlobalFont(gui_font.get());
|
gcn::Widget::setGlobalFont(gui_font);
|
||||||
gcn::Widget::setWidgetsBaseColor(gui_base_color);
|
gcn::Widget::setWidgetsBaseColor(gui_base_color);
|
||||||
gcn::Widget::setWidgetsForegroundColor(gui_foreground_color);
|
gcn::Widget::setWidgetsForegroundColor(gui_foreground_color);
|
||||||
gcn::Widget::setWidgetsBackgroundColor(gui_background_color);
|
gcn::Widget::setWidgetsBackgroundColor(gui_background_color);
|
||||||
|
|||||||
@ -156,19 +156,19 @@ static void InitShowMessage(const std::string& message)
|
|||||||
|
|
||||||
if (gui_graphics == nullptr)
|
if (gui_graphics == nullptr)
|
||||||
{
|
{
|
||||||
gui_graphics = std::make_unique<gcn::SDLGraphics>();
|
gui_graphics = new gcn::SDLGraphics();
|
||||||
gui_graphics->setTarget(gui_screen);
|
gui_graphics->setTarget(gui_screen);
|
||||||
}
|
}
|
||||||
if (gui_input == nullptr)
|
if (gui_input == nullptr)
|
||||||
{
|
{
|
||||||
gui_input = std::make_unique<gcn::SDLInput>();
|
gui_input = new gcn::SDLInput();
|
||||||
}
|
}
|
||||||
if (uae_gui == nullptr)
|
if (uae_gui == nullptr)
|
||||||
{
|
{
|
||||||
halt_gui = true;
|
halt_gui = true;
|
||||||
uae_gui = std::make_unique<gcn::Gui>();
|
uae_gui = new gcn::Gui();
|
||||||
uae_gui->setGraphics(gui_graphics.get());
|
uae_gui->setGraphics(gui_graphics);
|
||||||
uae_gui->setInput(gui_input.get());
|
uae_gui->setInput(gui_input);
|
||||||
}
|
}
|
||||||
if (gui_top == nullptr)
|
if (gui_top == nullptr)
|
||||||
{
|
{
|
||||||
@ -259,6 +259,14 @@ static void ExitShowMessage()
|
|||||||
|
|
||||||
if (halt_gui)
|
if (halt_gui)
|
||||||
{
|
{
|
||||||
|
delete uae_gui;
|
||||||
|
uae_gui = nullptr;
|
||||||
|
delete gui_input;
|
||||||
|
gui_input = nullptr;
|
||||||
|
delete gui_graphics;
|
||||||
|
gui_graphics = nullptr;
|
||||||
|
delete gui_font;
|
||||||
|
gui_font = nullptr;
|
||||||
delete gui_top;
|
delete gui_top;
|
||||||
gui_top = nullptr;
|
gui_top = nullptr;
|
||||||
|
|
||||||
|
|||||||
@ -173,8 +173,8 @@ extern bool gui_running;
|
|||||||
extern gcn::Container* selectors;
|
extern gcn::Container* selectors;
|
||||||
extern gcn::ScrollArea* selectorsScrollArea;
|
extern gcn::ScrollArea* selectorsScrollArea;
|
||||||
extern ConfigCategory categories[];
|
extern ConfigCategory categories[];
|
||||||
|
extern gcn::Gui* uae_gui;
|
||||||
extern gcn::Container* gui_top;
|
extern gcn::Container* gui_top;
|
||||||
extern std::unique_ptr<gcn::Gui> uae_gui;
|
|
||||||
|
|
||||||
// GUI Colors
|
// GUI Colors
|
||||||
extern amiberry_gui_theme gui_theme;
|
extern amiberry_gui_theme gui_theme;
|
||||||
@ -186,12 +186,12 @@ extern gcn::Color gui_selection_color;
|
|||||||
extern gcn::Color gui_foreground_color;
|
extern gcn::Color gui_foreground_color;
|
||||||
extern gcn::Color gui_font_color;
|
extern gcn::Color gui_font_color;
|
||||||
|
|
||||||
extern std::unique_ptr<gcn::SDLInput> gui_input;
|
extern gcn::SDLInput* gui_input;
|
||||||
extern SDL_Surface* gui_screen;
|
extern SDL_Surface* gui_screen;
|
||||||
extern SDL_Joystick* gui_joystick;
|
extern SDL_Joystick* gui_joystick;
|
||||||
|
|
||||||
extern std::unique_ptr<gcn::SDLGraphics> gui_graphics;
|
extern gcn::SDLGraphics* gui_graphics;
|
||||||
extern std::unique_ptr<gcn::SDLTrueTypeFont> gui_font;
|
extern gcn::SDLTrueTypeFont* gui_font;
|
||||||
extern SDL_Texture* gui_texture;
|
extern SDL_Texture* gui_texture;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -141,18 +141,18 @@ SDL_Rect gui_window_rect{0, 0, GUI_WIDTH, GUI_HEIGHT};
|
|||||||
/*
|
/*
|
||||||
* Gui SDL stuff we need
|
* Gui SDL stuff we need
|
||||||
*/
|
*/
|
||||||
std::unique_ptr<gcn::SDLInput> gui_input;
|
gcn::SDLInput* gui_input;
|
||||||
std::unique_ptr<gcn::SDLGraphics> gui_graphics;
|
gcn::SDLGraphics* gui_graphics;
|
||||||
std::unique_ptr<gcn::SDLImageLoader> gui_imageLoader;
|
gcn::SDLImageLoader* gui_imageLoader;
|
||||||
std::unique_ptr<gcn::SDLTrueTypeFont> gui_font;
|
gcn::SDLTrueTypeFont* gui_font;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Gui stuff we need
|
* Gui stuff we need
|
||||||
*/
|
*/
|
||||||
|
gcn::Gui* uae_gui;
|
||||||
gcn::Container* gui_top;
|
gcn::Container* gui_top;
|
||||||
gcn::Container* selectors;
|
gcn::Container* selectors;
|
||||||
gcn::ScrollArea* selectorsScrollArea;
|
gcn::ScrollArea* selectorsScrollArea;
|
||||||
std::unique_ptr<gcn::Gui> uae_gui;
|
|
||||||
|
|
||||||
// GUI Colors
|
// GUI Colors
|
||||||
gcn::Color gui_base_color;
|
gcn::Color gui_base_color;
|
||||||
@ -163,8 +163,8 @@ gcn::Color gui_selection_color;
|
|||||||
gcn::Color gui_foreground_color;
|
gcn::Color gui_foreground_color;
|
||||||
gcn::Color gui_font_color;
|
gcn::Color gui_font_color;
|
||||||
|
|
||||||
std::unique_ptr<gcn::FocusHandler> focusHdl;
|
gcn::FocusHandler* focusHdl;
|
||||||
std::unique_ptr<gcn::Widget> activeWidget;
|
gcn::Widget* activeWidget;
|
||||||
|
|
||||||
// Main buttons
|
// Main buttons
|
||||||
gcn::Button* cmdQuit;
|
gcn::Button* cmdQuit;
|
||||||
@ -392,24 +392,31 @@ void amiberry_gui_init()
|
|||||||
// Create helpers for GUI framework
|
// Create helpers for GUI framework
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
gui_imageLoader = std::make_unique<gcn::SDLImageLoader>();
|
gui_imageLoader = new gcn::SDLImageLoader();
|
||||||
gui_imageLoader->setRenderer(mon->gui_renderer);
|
gui_imageLoader->setRenderer(mon->gui_renderer);
|
||||||
|
|
||||||
// The ImageLoader in use is static and must be set to be
|
// The ImageLoader in use is static and must be set to be
|
||||||
// able to load images
|
// able to load images
|
||||||
gcn::Image::setImageLoader(gui_imageLoader.get());
|
gcn::Image::setImageLoader(gui_imageLoader);
|
||||||
gui_graphics = std::make_unique<gcn::SDLGraphics>();
|
gui_graphics = new gcn::SDLGraphics();
|
||||||
// Set the target for the graphics object to be the screen.
|
// Set the target for the graphics object to be the screen.
|
||||||
// In other words, we will draw to the screen.
|
// In other words, we will draw to the screen.
|
||||||
// Note, any surface will do, it doesn't have to be the screen.
|
// Note, any surface will do, it doesn't have to be the screen.
|
||||||
gui_graphics->setTarget(gui_screen);
|
gui_graphics->setTarget(gui_screen);
|
||||||
gui_input = std::make_unique<gcn::SDLInput>();
|
gui_input = new gcn::SDLInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
void amiberry_gui_halt()
|
void amiberry_gui_halt()
|
||||||
{
|
{
|
||||||
AmigaMonitor* mon = &AMonitors[0];
|
AmigaMonitor* mon = &AMonitors[0];
|
||||||
|
|
||||||
|
delete gui_imageLoader;
|
||||||
|
gui_imageLoader = nullptr;
|
||||||
|
delete gui_input;
|
||||||
|
gui_input = nullptr;
|
||||||
|
delete gui_graphics;
|
||||||
|
gui_graphics = nullptr;
|
||||||
|
|
||||||
if (gui_screen != nullptr)
|
if (gui_screen != nullptr)
|
||||||
{
|
{
|
||||||
SDL_FreeSurface(gui_screen);
|
SDL_FreeSurface(gui_screen);
|
||||||
@ -708,9 +715,9 @@ void check_input()
|
|||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
// Quit entire program via Q on keyboard
|
// Quit entire program via Q on keyboard
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
focusHdl.reset(gui_top->_getFocusHandler());
|
focusHdl = gui_top->_getFocusHandler();
|
||||||
activeWidget.reset(focusHdl->getFocused());
|
activeWidget = focusHdl->getFocused();
|
||||||
if (dynamic_cast<gcn::TextField*>(activeWidget.get()) == nullptr)
|
if (dynamic_cast<gcn::TextField*>(activeWidget) == nullptr)
|
||||||
{
|
{
|
||||||
// ...but only if we are not in a Textfield...
|
// ...but only if we are not in a Textfield...
|
||||||
uae_quit();
|
uae_quit();
|
||||||
@ -1016,9 +1023,9 @@ void gui_widgets_init()
|
|||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
// Create GUI
|
// Create GUI
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
uae_gui = std::make_unique<gcn::Gui>();
|
uae_gui = new gcn::Gui();
|
||||||
uae_gui->setGraphics(gui_graphics.get());
|
uae_gui->setGraphics(gui_graphics);
|
||||||
uae_gui->setInput(gui_input.get());
|
uae_gui->setInput(gui_input);
|
||||||
|
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
// Initialize fonts
|
// Initialize fonts
|
||||||
@ -1197,9 +1204,15 @@ void gui_widgets_halt()
|
|||||||
delete cmdRestart;
|
delete cmdRestart;
|
||||||
delete cmdStart;
|
delete cmdStart;
|
||||||
delete cmdHelp;
|
delete cmdHelp;
|
||||||
|
|
||||||
delete mainButtonActionListener;
|
delete mainButtonActionListener;
|
||||||
|
|
||||||
|
delete gui_font;
|
||||||
|
gui_font = nullptr;
|
||||||
delete gui_top;
|
delete gui_top;
|
||||||
gui_top = nullptr;
|
gui_top = nullptr;
|
||||||
|
delete uae_gui;
|
||||||
|
uae_gui = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void refresh_all_panels()
|
void refresh_all_panels()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user