reduce unnecessary #include dependency chains

for example, elements no longer include Client.h or Graphics.h, and interface stuff won't include Window.h or Graphics.h unless requested
This commit is contained in:
jacob1 2017-07-13 23:24:35 -04:00
parent 781a90a970
commit 5ee10d14e4
71 changed files with 307 additions and 270 deletions

View File

@ -26,17 +26,11 @@ public:
}
virtual void Show()
{
if(ui::Engine::Ref().GetWindow() != this)
{
ui::Engine::Ref().ShowWindow(this);
}
MakeActiveWindow();
}
virtual void Hide()
{
if(ui::Engine::Ref().GetWindow() == this)
{
ui::Engine::Ref().CloseWindow();
}
CloseActiveWindow();
}
virtual ~WindowActivity() {}
};

View File

@ -1,5 +1,4 @@
#include "DebugLines.h"
#include "gui/interface/Engine.h"
#include "gui/game/GameView.h"
#include "gui/game/GameController.h"
@ -13,7 +12,7 @@ DebugLines::DebugLines(unsigned int id, GameView * view, GameController * contro
void DebugLines::Draw()
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = view->GetGraphics();
if (view->GetDrawingLine())
{

View File

@ -1,7 +1,8 @@
#include <iomanip>
#include <sstream>
#include "DebugParts.h"
#include "gui/interface/Engine.h"
#include "simulation/Simulation.h"
#include <iomanip>
DebugParts::DebugParts(unsigned int id, Simulation * sim):
DebugInfo(id),

View File

@ -9,98 +9,8 @@
#include "OpenGLHeaders.h"
#endif
#include "Config.h"
//#include "powder.h"
#define PIXELCHANNELS 3
#ifdef PIX16
#define PIXELSIZE 2
#define PIXPACK(x) ((((x)>>8)&0xF800)|(((x)>>5)&0x07E0)|(((x)>>3)&0x001F)) //16bit RGB in 16bit int: ????
#define PIXRGB(r,g,b) ((((r)<<8)&0xF800)|(((g)<<3)&0x07E0)|(((b)>>3)&0x001F))
#define PIXR(x) (((x)>>8)&0xF8)
#define PIXG(x) (((x)>>3)&0xFC)
#define PIXB(x) (((x)<<3)&0xF8)
#else
#define PIXELSIZE 4
#ifdef PIX32BGRA
#define PIXPACK(x) ((((x)>>16)&0x0000FF)|((x)&0x00FF00)|(((x)<<16)&0xFF0000)) //24bit BGR in 32bit int: 00BBGGRR
#define PIXRGB(r,g,b) (((b)<<16)|((g)<<8)|((r)))// (((b)<<16)|((g)<<8)|(r))
#define PIXR(x) ((x)&0xFF)
#define PIXG(x) (((x)>>8)&0xFF)
#define PIXB(x) ((x)>>16)
#else
#ifdef PIX32BGRA
#define PIXPACK(x) ((((x)>>8)&0x0000FF00)|(((x)<<8)&0x00FF0000)|(((x)<<24)&0xFF000000)) //32bit BGRA in 32bit int: BBGGRRAA
#define PIXRGB(r,g,b) (((b)<<24)|((g)<<16)|((r)<<8))
#define PIXR(x) (((x)>>8)&0xFF)
#define PIXG(x) (((x)>>16)&0xFF)
#define PIXB(x) (((x)>>24)&0xFF)
#elif defined(PIX32OGL)
#undef PIXELCHANNELS
#define PIXELCHANNELS 4
#define PIXPACK(x) (0xFF000000|((x)&0xFFFFFF)) //32bit ARGB in 32bit int: AARRGGBB
#define PIXRGB(r,g,b) (0xFF000000|((r)<<16)|((g)<<8)|((b)))
#define PIXRGBA(r,g,b,a) (((a)<<24)|((r)<<16)|((g)<<8)|((b)))
#define PIXA(x) (((x)>>24)&0xFF)
#define PIXR(x) (((x)>>16)&0xFF)
#define PIXG(x) (((x)>>8)&0xFF)
#define PIXB(x) ((x)&0xFF)
#else
#define PIXPACK(x) (x) //24bit RGB in 32bit int: 00RRGGBB.
#define PIXRGB(r,g,b) (((r)<<16)|((g)<<8)|(b))
#define PIXR(x) (((x)>>16)&0xFF)
#define PIXG(x) (((x)>>8)&0xFF)
#define PIXB(x) ((x)&0xFF)
#endif
#endif
#endif
#ifdef PIX16
typedef unsigned short pixel;
#else
typedef unsigned int pixel;
#endif
//Icon names, see Graphics::draw_icon
enum Icon
{
NoIcon = 0,
IconOpen,
IconReload,
IconSave,
IconVoteUp,
IconVoteDown,
IconTag,
IconNew,
IconLogin,
IconRenderSettings,
IconSimulationSettings,
IconPause,
IconVoteSort,
IconDateSort,
IconMyOwn,
IconFavourite,
IconSearch,
IconDelete,
IconAdd,
IconReport,
IconUsername,
IconPassword,
IconClose,
IconEffect,
IconFire,
IconGlow,
IconBlur,
IconBlob,
IconBasic,
IconAltAir,
IconPressure,
IconVelocity,
IconWarp,
IconPersistant,
IconHeat,
IconLife,
IconGradient
};
#include "Pixel.h"
#include "Icons.h"
//"Graphics lite" - slightly lower performance due to variable size,
class VideoBuffer

46
src/graphics/Icons.h Normal file
View File

@ -0,0 +1,46 @@
#ifndef ICONS_H
#define ICONS_H
//Icon names, see Graphics::draw_icon
enum Icon
{
NoIcon = 0,
IconOpen,
IconReload,
IconSave,
IconVoteUp,
IconVoteDown,
IconTag,
IconNew,
IconLogin,
IconRenderSettings,
IconSimulationSettings,
IconPause,
IconVoteSort,
IconDateSort,
IconMyOwn,
IconFavourite,
IconSearch,
IconDelete,
IconAdd,
IconReport,
IconUsername,
IconPassword,
IconClose,
IconEffect,
IconFire,
IconGlow,
IconBlur,
IconBlob,
IconBasic,
IconAltAir,
IconPressure,
IconVelocity,
IconWarp,
IconPersistant,
IconHeat,
IconLife,
IconGradient
};
#endif // ICONS_H

53
src/graphics/Pixel.h Normal file
View File

@ -0,0 +1,53 @@
#ifndef PIXEL_H
#define PIXEL_H
#define PIXELCHANNELS 3
#ifdef PIX16
#define PIXELSIZE 2
#define PIXPACK(x) ((((x)>>8)&0xF800)|(((x)>>5)&0x07E0)|(((x)>>3)&0x001F)) //16bit RGB in 16bit int: ????
#define PIXRGB(r,g,b) ((((r)<<8)&0xF800)|(((g)<<3)&0x07E0)|(((b)>>3)&0x001F))
#define PIXR(x) (((x)>>8)&0xF8)
#define PIXG(x) (((x)>>3)&0xFC)
#define PIXB(x) (((x)<<3)&0xF8)
#else
#define PIXELSIZE 4
#ifdef PIX32BGRA
#define PIXPACK(x) ((((x)>>16)&0x0000FF)|((x)&0x00FF00)|(((x)<<16)&0xFF0000)) //24bit BGR in 32bit int: 00BBGGRR
#define PIXRGB(r,g,b) (((b)<<16)|((g)<<8)|((r)))// (((b)<<16)|((g)<<8)|(r))
#define PIXR(x) ((x)&0xFF)
#define PIXG(x) (((x)>>8)&0xFF)
#define PIXB(x) ((x)>>16)
#else
#ifdef PIX32BGRA
#define PIXPACK(x) ((((x)>>8)&0x0000FF00)|(((x)<<8)&0x00FF0000)|(((x)<<24)&0xFF000000)) //32bit BGRA in 32bit int: BBGGRRAA
#define PIXRGB(r,g,b) (((b)<<24)|((g)<<16)|((r)<<8))
#define PIXR(x) (((x)>>8)&0xFF)
#define PIXG(x) (((x)>>16)&0xFF)
#define PIXB(x) (((x)>>24)&0xFF)
#elif defined(PIX32OGL)
#undef PIXELCHANNELS
#define PIXELCHANNELS 4
#define PIXPACK(x) (0xFF000000|((x)&0xFFFFFF)) //32bit ARGB in 32bit int: AARRGGBB
#define PIXRGB(r,g,b) (0xFF000000|((r)<<16)|((g)<<8)|((b)))
#define PIXRGBA(r,g,b,a) (((a)<<24)|((r)<<16)|((g)<<8)|((b)))
#define PIXA(x) (((x)>>24)&0xFF)
#define PIXR(x) (((x)>>16)&0xFF)
#define PIXG(x) (((x)>>8)&0xFF)
#define PIXB(x) ((x)&0xFF)
#else
#define PIXPACK(x) (x) //24bit RGB in 32bit int: 00RRGGBB.
#define PIXRGB(r,g,b) (((r)<<16)|((g)<<8)|(b))
#define PIXR(x) (((x)>>16)&0xFF)
#define PIXG(x) (((x)>>8)&0xFF)
#define PIXB(x) ((x)&0xFF)
#endif
#endif
#endif
#ifdef PIX16
typedef unsigned short pixel;
#else
typedef unsigned int pixel;
#endif
#endif // PIXEL_H

View File

@ -4,8 +4,10 @@
#include <cstdio>
#include <cstdlib>
#include "Config.h"
#include "Misc.h"
#include "Renderer.h"
#include "Graphics.h"
#include "gui/game/RenderPreset.h"
#include "simulation/Elements.h"
#include "simulation/ElementGraphics.h"
#include "simulation/Air.h"

View File

@ -7,13 +7,11 @@
#endif
#include "Config.h"
#include "client/Client.h"
#include "Graphics.h"
#include "gui/interface/Point.h"
#include "gui/game/RenderPreset.h"
class RenderPreset;
class Simulation;
class Graphics;
struct gcache_item

View File

@ -258,7 +258,7 @@ void ColourPickerActivity::OnKeyPress(int key, Uint16 character, bool shift, boo
void ColourPickerActivity::OnDraw()
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
//g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3);
g->fillrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3, 0, 0, 0, currentAlpha);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255);

View File

@ -28,8 +28,7 @@ void ConsoleController::EvaluateCommand(std::string command)
void ConsoleController::CloseConsole()
{
if(ui::Engine::Ref().GetWindow() == consoleView)
ui::Engine::Ref().CloseWindow();
consoleView->CloseActiveWindow();
}
std::string ConsoleController::FormatCommand(std::string command)
@ -53,9 +52,8 @@ void ConsoleController::PreviousCommand()
void ConsoleController::Exit()
{
if(ui::Engine::Ref().GetWindow() == consoleView)
ui::Engine::Ref().CloseWindow();
if(callback)
consoleView->CloseActiveWindow();
if (callback)
callback->ControllerExit();
HasDone = true;
}
@ -65,9 +63,9 @@ ConsoleView * ConsoleController::GetView()
return consoleView;
}
ConsoleController::~ConsoleController() {
if(ui::Engine::Ref().GetWindow() == consoleView)
ui::Engine::Ref().CloseWindow();
ConsoleController::~ConsoleController()
{
consoleView->CloseActiveWindow();
delete callback;
delete consoleModel;
delete consoleView;

View File

@ -91,7 +91,7 @@ void ConsoleView::NotifyCurrentCommandChanged(ConsoleModel * sender)
void ConsoleView::OnDraw()
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
g->fillrect(Position.X, Position.Y, Size.X, Size.Y, 0, 0, 0, 110);
g->draw_line(Position.X, Position.Y+Size.Y-16, Position.X+Size.X, Position.Y+Size.Y-16, 255, 255, 255, 160);
g->draw_line(Position.X, Position.Y+Size.Y, Position.X+Size.X, Position.Y+Size.Y, 255, 255, 255, 200);

View File

@ -1,7 +1,8 @@
#include "ConfirmPrompt.h"
#include "gui/Style.h"
#include "gui/interface/Label.h"
#include "gui/interface/Button.h"
#include "gui/interface/Engine.h"
#include "gui/interface/Label.h"
#include "gui/interface/ScrollPanel.h"
#include "PowderToy.h"
@ -40,7 +41,7 @@ ConfirmPrompt::ConfirmPrompt(std::string title, std::string message, ConfirmDial
CloseAction(ConfirmPrompt * prompt_, DialogueResult result_) { prompt = prompt_; result = result_; }
void ActionCallback(ui::Button * sender)
{
ui::Engine::Ref().CloseWindow();
prompt->CloseActiveWindow();
if(prompt->callback)
prompt->callback->ConfirmCallback(result);
prompt->SelfDestruct();
@ -64,7 +65,7 @@ ConfirmPrompt::ConfirmPrompt(std::string title, std::string message, ConfirmDial
AddComponent(okayButton);
SetOkayButton(okayButton);
ui::Engine::Ref().ShowWindow(this);
MakeActiveWindow();
}
ConfirmPrompt::ConfirmPrompt(std::string title, std::string message, std::string buttonText, ConfirmDialogueCallback * callback_):
@ -102,7 +103,7 @@ ConfirmPrompt::ConfirmPrompt(std::string title, std::string message, std::string
CloseAction(ConfirmPrompt * prompt_, DialogueResult result_) { prompt = prompt_; result = result_; }
void ActionCallback(ui::Button * sender)
{
ui::Engine::Ref().CloseWindow();
prompt->CloseActiveWindow();
if(prompt->callback)
prompt->callback->ConfirmCallback(result);
prompt->SelfDestruct();
@ -126,7 +127,7 @@ ConfirmPrompt::ConfirmPrompt(std::string title, std::string message, std::string
AddComponent(okayButton);
SetOkayButton(okayButton);
ui::Engine::Ref().ShowWindow(this);
MakeActiveWindow();
}
bool ConfirmPrompt::Blocking(std::string title, std::string message, std::string buttonText)
@ -152,7 +153,7 @@ bool ConfirmPrompt::Blocking(std::string title, std::string message, std::string
void ConfirmPrompt::OnDraw()
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255);

View File

@ -1,6 +1,7 @@
#ifndef CONFIRMPROMPT_H_
#define CONFIRMPROMPT_H_
#include <string>
#include "gui/interface/Window.h"
class ConfirmDialogueCallback;

View File

@ -1,6 +1,7 @@
#include "gui/Style.h"
#include "ErrorMessage.h"
#include "gui/interface/Button.h"
#include "gui/interface/Engine.h"
#include "gui/interface/Label.h"
#include "PowderToy.h"
@ -30,7 +31,7 @@ ErrorMessage::ErrorMessage(std::string title, std::string message, ErrorMessage
DismissAction(ErrorMessage * message_) { message = message_; }
void ActionCallback(ui::Button * sender)
{
ui::Engine::Ref().CloseWindow();
message->CloseActiveWindow();
if(message->callback)
message->callback->DismissCallback();
message->SelfDestruct();
@ -46,7 +47,7 @@ ErrorMessage::ErrorMessage(std::string title, std::string message, ErrorMessage
SetOkayButton(okayButton);
SetCancelButton(okayButton);
ui::Engine::Ref().ShowWindow(this);
MakeActiveWindow();
}
void ErrorMessage::Blocking(std::string title, std::string message)
@ -65,7 +66,7 @@ void ErrorMessage::Blocking(std::string title, std::string message)
void ErrorMessage::OnDraw()
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255);

View File

@ -1,6 +1,7 @@
#include "gui/Style.h"
#include "InformationMessage.h"
#include "gui/interface/Button.h"
#include "gui/interface/Engine.h"
#include "gui/interface/Label.h"
#include "gui/interface/ScrollPanel.h"
@ -58,7 +59,7 @@ InformationMessage::InformationMessage(std::string title, std::string message, b
DismissAction(InformationMessage * message_) { message = message_; }
void ActionCallback(ui::Button * sender)
{
ui::Engine::Ref().CloseWindow();
message->CloseActiveWindow();
message->SelfDestruct(); //TODO: Fix component disposal
}
};
@ -72,12 +73,12 @@ InformationMessage::InformationMessage(std::string title, std::string message, b
SetOkayButton(okayButton);
SetCancelButton(okayButton);
ui::Engine::Ref().ShowWindow(this);
MakeActiveWindow();
}
void InformationMessage::OnDraw()
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255);

View File

@ -1,5 +1,6 @@
#include "gui/Style.h"
#include "SaveIDMessage.h"
#include "graphics/Graphics.h"
#include "gui/interface/Button.h"
#include "gui/interface/CopyTextButton.h"
#include "gui/interface/Label.h"
@ -38,7 +39,7 @@ SaveIDMessage::SaveIDMessage(int id):
DismissAction(SaveIDMessage * message_) { message = message_; }
void ActionCallback(ui::Button * sender)
{
ui::Engine::Ref().CloseWindow();
message->CloseActiveWindow();
message->SelfDestruct();
}
};
@ -50,12 +51,12 @@ SaveIDMessage::SaveIDMessage(int id):
AddComponent(okayButton);
SetCancelButton(okayButton);
ui::Engine::Ref().ShowWindow(this);
MakeActiveWindow();
}
void SaveIDMessage::OnDraw()
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255);
@ -63,7 +64,7 @@ void SaveIDMessage::OnDraw()
void SaveIDMessage::OnTryExit(ExitMethod method)
{
ui::Engine::Ref().CloseWindow();
CloseActiveWindow();
SelfDestruct();
}

View File

@ -2,6 +2,7 @@
#include "TextPrompt.h"
#include "gui/interface/Label.h"
#include "gui/interface/Button.h"
#include "gui/interface/Engine.h"
#include "gui/Style.h"
#include "PowderToy.h"
@ -13,7 +14,7 @@ public:
CloseAction(TextPrompt * prompt_, TextPrompt::DialogueResult result_) { prompt = prompt_; result = result_; }
void ActionCallback(ui::Button * sender)
{
ui::Engine::Ref().CloseWindow();
prompt->CloseActiveWindow();
if(prompt->callback)
prompt->callback->TextCallback(result, prompt->textField->GetText());
prompt->SelfDestruct(); //TODO: Fix component disposal
@ -73,7 +74,7 @@ TextPrompt::TextPrompt(std::string title, std::string message, std::string text,
AddComponent(okayButton);
SetOkayButton(okayButton);
ui::Engine::Ref().ShowWindow(this);
MakeActiveWindow();
}
std::string TextPrompt::Blocking(std::string title, std::string message, std::string text, std::string placeholder, bool multiline)
@ -101,7 +102,7 @@ std::string TextPrompt::Blocking(std::string title, std::string message, std::st
void TextPrompt::OnDraw()
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255);

View File

@ -188,7 +188,7 @@ void ElementSearchActivity::SetActiveTool(int selectionState, Tool * tool)
void ElementSearchActivity::OnDraw()
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255);

View File

@ -327,7 +327,7 @@ void FileBrowserActivity::OnTick(float dt)
void FileBrowserActivity::OnDraw()
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
//Window Background+Outline
g->clearrect(Position.X-2, Position.Y-2, Size.X+4, Size.Y+4);

View File

@ -224,9 +224,8 @@ GameController::~GameController()
delete *iter;
}
delete gameModel;
if (ui::Engine::Ref().GetWindow() == gameView)
if (gameView->CloseActiveWindow())
{
ui::Engine::Ref().CloseWindow();
delete gameView;
}
}
@ -835,8 +834,7 @@ void GameController::Tick()
void GameController::Exit()
{
if(ui::Engine::Ref().GetWindow() == gameView)
ui::Engine::Ref().CloseWindow();
gameView->CloseActiveWindow();
HasDone = true;
}
@ -1365,7 +1363,7 @@ void GameController::OpenOptions()
void GameController::ShowConsole()
{
if(!console)
if (!console)
console = new ConsoleController(NULL, commandInterface);
if (console->GetView() != ui::Engine::Ref().GetWindow())
ui::Engine::Ref().ShowWindow(console->GetView());
@ -1373,10 +1371,9 @@ void GameController::ShowConsole()
void GameController::HideConsole()
{
if(!console)
if (!console)
return;
if (console->GetView() == ui::Engine::Ref().GetWindow())
ui::Engine::Ref().CloseWindow();
console->GetView()->CloseActiveWindow();
}
void GameController::OpenRenderOptions()

View File

@ -20,6 +20,7 @@ using namespace std;
class GameView;
class GameController;
class SaveFile;
class Simulation;
class Renderer;

View File

@ -138,7 +138,7 @@ public:
void Draw(const ui::Point& screenPos)
{
ui::Button::Draw(screenPos);
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
drawn = true;
if(showSplit)
@ -2092,7 +2092,7 @@ void GameView::SetSaveButtonTooltips()
void GameView::OnDraw()
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
if (ren)
{
ren->clearScreen(1.0f);

View File

@ -1,9 +1,9 @@
#include <iostream>
#include <sstream>
#include "Tool.h"
#include "client/Client.h"
#include "gui/Style.h"
#include "gui/game/Brush.h"
#include "simulation/Simulation.h"
#include "Tool.h"
#include "gui/interface/Window.h"
#include "gui/interface/Button.h"
#include "gui/interface/Label.h"
@ -11,6 +11,7 @@
#include "gui/interface/DropDown.h"
#include "gui/interface/Keys.h"
#include "gui/dialogues/ErrorMessage.h"
#include "simulation/Simulation.h"
class PropertyWindow: public ui::Window
{
@ -33,7 +34,7 @@ public:
OkayAction(PropertyWindow * prompt_) { prompt = prompt_; }
void ActionCallback(ui::Button * sender)
{
ui::Engine::Ref().CloseWindow();
prompt->CloseActiveWindow();
if(prompt->textField->GetText().length())
prompt->SetProperty();
prompt->SelfDestruct();
@ -89,7 +90,7 @@ sim(sim_)
AddComponent(textField);
FocusComponent(textField);
ui::Engine::Ref().ShowWindow(this);
MakeActiveWindow();
}
void PropertyWindow::SetProperty()
@ -217,13 +218,13 @@ void PropertyWindow::SetProperty()
void PropertyWindow::OnTryExit(ExitMethod method)
{
ui::Engine::Ref().CloseWindow();
CloseActiveWindow();
SelfDestruct();
}
void PropertyWindow::OnDraw()
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255);

View File

@ -38,7 +38,7 @@ public:
OkayAction(SignWindow * prompt_) { prompt = prompt_; }
void ActionCallback(ui::Button * sender)
{
ui::Engine::Ref().CloseWindow();
prompt->CloseActiveWindow();
if(prompt->signID==-1 && prompt->textField->GetText().length())
{
prompt->sim->signs.push_back(sign(prompt->textField->GetText(), prompt->signPosition.X, prompt->signPosition.Y, (sign::Justification)prompt->justification->GetOption().second));
@ -57,7 +57,7 @@ public:
DeleteAction(SignWindow * prompt_) { prompt = prompt_; }
void ActionCallback(ui::Button * sender)
{
ui::Engine::Ref().CloseWindow();
prompt->CloseActiveWindow();
if(prompt->signID!=-1)
{
prompt->sim->signs.erase(prompt->sim->signs.begin()+prompt->signID);
@ -166,12 +166,12 @@ SignWindow::SignWindow(SignTool * tool_, Simulation * sim_, int signID_, ui::Poi
AddComponent(deleteButton);
}
ui::Engine::Ref().ShowWindow(this);
MakeActiveWindow();
}
void SignWindow::OnTryExit(ui::Window::ExitMethod method)
{
ui::Engine::Ref().CloseWindow();
CloseActiveWindow();
SelfDestruct();
}
@ -182,7 +182,7 @@ void SignWindow::DoDraw()
sign & currentSign = *iter;
int x, y, w, h, dx, dy;
char type = 0;
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
std::string text = currentSign.getText(sim);
sign::splitsign(currentSign.text.c_str(), &type);
currentSign.pos(text, x, y, w, h);
@ -251,7 +251,7 @@ void SignWindow::DoMouseDown(int x, int y, unsigned button)
void SignWindow::OnDraw()
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255);

View File

@ -1,4 +1,5 @@
#include "ToolButton.h"
#include "graphics/Graphics.h"
#include "gui/interface/Keys.h"
#include "gui/interface/Mouse.h"
#include "Favorite.h"
@ -44,7 +45,7 @@ void ToolButton::OnMouseUp(int x, int y, unsigned int button)
void ToolButton::Draw(const ui::Point& screenPos)
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
int totalColour = Appearance.BackgroundInactive.Blue + (3*Appearance.BackgroundInactive.Green) + (2*Appearance.BackgroundInactive.Red);
if (Appearance.GetTexture())

View File

@ -1,5 +1,6 @@
#include <iostream>
#include "Appearance.h"
#include "graphics/Graphics.h"
namespace ui
{

View File

@ -3,8 +3,9 @@
#include "Border.h"
#include "Colour.h"
#include "graphics/Graphics.h"
#include "graphics/Icons.h"
class VideoBuffer;
namespace ui
{
class Appearance

View File

@ -3,7 +3,6 @@
#include "AvatarButton.h"
#include "Format.h"
#include "Engine.h"
#include "client/Client.h"
#include "client/requestbroker/RequestBroker.h"
#include "graphics/Graphics.h"
@ -51,7 +50,7 @@ void AvatarButton::OnResponseReady(void * imagePtr, int identifier)
void AvatarButton::Draw(const Point& screenPos)
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
if(avatar)
{

View File

@ -1,7 +1,7 @@
#include <iostream>
#include "gui/interface/Button.h"
#include "gui/interface/Window.h"
#include "graphics/Graphics.h"
#include "Engine.h"
#include "Misc.h"
namespace ui {
@ -75,7 +75,7 @@ void Button::Draw(const Point& screenPos)
TextPosition(ButtonText);
drawn = true;
}
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
Point Position = screenPos;
ui::Colour bgColour(0, 0, 0);

View File

@ -1,4 +1,6 @@
#include "Checkbox.h"
#include "graphics/Graphics.h"
#include "gui/interface/Window.h"
using namespace ui;
@ -70,7 +72,7 @@ void Checkbox::OnMouseLeave(int x, int y)
void Checkbox::Draw(const Point& screenPos)
{
Graphics * g = Engine::Ref().g;
Graphics * g = GetGraphics();
if(checked)
{
g->fillrect(screenPos.X+5, screenPos.Y+5, 6, 6, 255, 255, 255, 255);

View File

@ -1,4 +1,5 @@
#include <iostream>
#include "graphics/Graphics.h"
#include "gui/interface/Component.h"
#include "gui/interface/Engine.h"
#include "gui/interface/Point.h"
@ -167,6 +168,11 @@ Point Component::GetScreenPos()
return newPos;
}
Graphics * Component::GetGraphics()
{
return parentstate_->GetGraphics();
}
// ***** OVERRIDEABLES *****
// Kept empty.

View File

@ -1,9 +1,11 @@
#pragma once
#include <string>
#include "Config.h"
#include "Appearance.h"
#include "Point.h"
#include "Window.h"
class Graphics;
namespace ui
{
class ContextMenu;
@ -26,6 +28,7 @@ namespace ui
ui::Point textSize;
ui::Point iconPosition;
ui::ContextMenu * menu;
Graphics * GetGraphics();
public:
Component(Window* parent_state);
Component(Point position, Point size);

View File

@ -1,5 +1,6 @@
#include "ContextMenu.h"
#include "common/tpt-minmax.h"
#include "graphics/Graphics.h"
using namespace ui;
@ -52,20 +53,21 @@ void ContextMenu::Show(ui::Point position)
currentY += 15;
}
ui::Engine::Ref().ShowWindow(this);
MakeActiveWindow();
}
void ContextMenu::ActionCallbackItem(ui::Button *sender, int item)
{
ui::Engine::Ref().CloseWindow();
CloseActiveWindow();
Halt();
source->OnContextMenuAction(item);
}
void ContextMenu::OnMouseDown(int x, int y, unsigned button)
{
if(!(x > Position.X && y > Position.Y && y < Position.Y+Size.Y && x < Position.X+Size.X)) //Clicked outside window
ui::Engine::Ref().CloseWindow();
// Clicked outside window
if (!(x > Position.X && y > Position.Y && y < Position.Y+Size.Y && x < Position.X+Size.X))
CloseActiveWindow();
}
void ContextMenu::SetItem(int id, std::string text)
@ -99,7 +101,7 @@ void ContextMenu::AddItem(ContextMenuItem item)
void ContextMenu::OnDraw()
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
g->fillrect(Position.X, Position.Y, Size.X, Size.Y, 100, 100, 100, 255);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, Appearance.BackgroundInactive.Red, Appearance.BackgroundInactive.Green, Appearance.BackgroundInactive.Blue, Appearance.BackgroundInactive.Alpha);
}

View File

@ -1,5 +1,6 @@
#include "CopyTextButton.h"
#include "Colour.h"
#include "PowderToy.h"
#include "gui/Style.h"
namespace ui

View File

@ -1,7 +1,9 @@
#include <iostream>
#include "graphics/Graphics.h"
#include "gui/Style.h"
#include "Button.h"
#include "DropDown.h"
#include "gui/interface/Window.h"
namespace ui {
@ -21,7 +23,7 @@ public:
ItemSelectedAction(DropDownWindow * window, std::string option): window(window), option(option) { }
virtual void ActionCallback(ui::Button *sender)
{
ui::Engine::Ref().CloseWindow();
window->CloseActiveWindow();
window->setOption(option);
window->SelfDestruct();
}
@ -45,7 +47,7 @@ public:
}
virtual void OnDraw()
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
g->clearrect(Position.X, Position.Y, Size.X, Size.Y);
}
void setOption(std::string option)
@ -64,7 +66,7 @@ public:
}
virtual void OnTryExit(ExitMethod method)
{
ui::Engine::Ref().CloseWindow();
CloseActiveWindow();
SelfDestruct();
}
virtual ~DropDownWindow() {}
@ -81,7 +83,7 @@ DropDown::DropDown(Point position, Point size):
void DropDown::OnMouseClick(int x, int y, unsigned int button)
{
DropDownWindow * newWindow = new DropDownWindow(this);
ui::Engine::Ref().ShowWindow(newWindow);
newWindow->MakeActiveWindow();
}
void DropDown::Draw(const Point& screenPos)
@ -92,7 +94,7 @@ void DropDown::Draw(const Point& screenPos)
TextPosition(options[optionIndex].first);
drawn = true;
}
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
Point Position = screenPos;
ui::Colour textColour = Appearance.TextInactive;

View File

@ -5,7 +5,9 @@
#include "Label.h"
#include "Keys.h"
#include "Mouse.h"
#include "PowderToy.h"
#include "ContextMenu.h"
#include "graphics/Graphics.h"
using namespace ui;
@ -380,7 +382,7 @@ void Label::Draw(const Point& screenPos)
TextPosition(text);
drawn = true;
}
Graphics * g = Engine::Ref().g;
Graphics * g = GetGraphics();
std::string cDisplayText = displayText;

View File

@ -4,7 +4,6 @@
#include <string>
#include "Component.h"
#include "PowderToy.h"
#include "Colour.h"
namespace ui

View File

@ -1,7 +1,7 @@
#include <vector>
#include "gui/interface/Panel.h"
#include "gui/interface/Engine.h"
#include "gui/interface/Point.h"
#include "gui/interface/Window.h"
#include "gui/interface/Component.h"

View File

@ -1,6 +1,7 @@
#pragma once
#include <vector>
#include "graphics/Pixel.h"
#include "gui/interface/Point.h"
#include "gui/interface/Window.h"
#include "gui/interface/Component.h"

View File

@ -1,5 +1,6 @@
#include "ProgressBar.h"
#include "common/tpt-minmax.h"
#include "graphics/Graphics.h"
#include "gui/Style.h"
using namespace ui;
@ -38,7 +39,7 @@ std::string ProgressBar::GetStatus()
void ProgressBar::Draw(const Point & screenPos)
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
ui::Colour progressBarColour = style::Colour::WarningTitle;

View File

@ -175,7 +175,7 @@ std::string RichLabel::GetText()
void RichLabel::Draw(const Point& screenPos)
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
ui::Colour textColour = Appearance.TextInactive;
g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, displayText, textColour.Red, textColour.Green, textColour.Blue, 255);
}

View File

@ -4,7 +4,6 @@
#include "SaveButton.h"
#include "client/SaveInfo.h"
#include "graphics/Graphics.h"
#include "Engine.h"
#include "client/requestbroker/RequestBroker.h"
#include "simulation/SaveRenderer.h"
#include "Format.h"
@ -165,7 +164,7 @@ void SaveButton::Tick(float dt)
void SaveButton::Draw(const Point& screenPos)
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
float scaleFactor;
ui::Point thumbBoxSize(0, 0);

View File

@ -1,6 +1,7 @@
#include <iostream>
#include "ScrollPanel.h"
#include "common/tpt-minmax.h"
#include "graphics/Graphics.h"
using namespace ui;
@ -48,7 +49,7 @@ void ScrollPanel::Draw(const Point& screenPos)
{
Panel::Draw(screenPos);
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
//Vertical scroll bar
if (maxOffset.Y>0 && InnerSize.Y>0)

View File

@ -1,6 +1,7 @@
#include <iostream>
#include "Slider.h"
#include "Colour.h"
#include "graphics/Graphics.h"
namespace ui {
@ -104,7 +105,7 @@ void Slider::SetSteps(int steps)
void Slider::Draw(const Point& screenPos)
{
Graphics * g = Engine::Ref().g;
Graphics * g = GetGraphics();
//g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 255, 255, 255, 255);
if(bgGradient)

View File

@ -1,6 +1,7 @@
#include <cmath>
#include <iostream>
#include "Spinner.h"
#include "graphics/Graphics.h"
using namespace ui;
@ -20,7 +21,7 @@ void Spinner::Tick(float dt)
}
void Spinner::Draw(const Point& screenPos)
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
int baseX = screenPos.X+(Size.X/2);
int baseY = screenPos.Y+(Size.Y/2);
int lineInner = (Size.X/2);

View File

@ -4,6 +4,7 @@
#include "Config.h"
#include "Platform.h"
#include "Format.h"
#include "graphics/Graphics.h"
#include "gui/interface/Point.h"
#include "gui/interface/Textbox.h"
#include "gui/interface/Keys.h"
@ -532,7 +533,7 @@ void Textbox::Draw(const Point& screenPos)
{
Label::Draw(screenPos);
Graphics * g = Engine::Ref().g;
Graphics * g = GetGraphics();
if(IsFocused())
{
if(border) g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 255, 255, 255, 255);
@ -694,7 +695,7 @@ void Textbox::Draw(const Point& screenPos)
TextPosition();
drawn = true;
}
Graphics * g = Engine::Ref().g;
Graphics * g = GetGraphics();
if(IsFocused())
{
if(border) g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 255, 255, 255, 255);

View File

@ -1,5 +1,6 @@
#include <iostream>
#include "Window.h"
#include "Engine.h"
#include "Keys.h"
#include "Component.h"
#include "gui/interface/Point.h"
@ -118,6 +119,27 @@ void Window::FocusComponent(Component* c)
this->focusedComponent_ = c;
}
void Window::MakeActiveWindow()
{
if (Engine::Ref().GetWindow() != this)
Engine::Ref().ShowWindow(this);
}
bool Window::CloseActiveWindow()
{
if (Engine::Ref().GetWindow() == this)
{
Engine::Ref().CloseWindow();
return true;
}
return false;
}
Graphics * Window::GetGraphics()
{
return Engine::Ref().g;
}
void Window::DoExit()
{
OnExit();

View File

@ -1,10 +1,12 @@
#ifndef WINDOW_H
#define WINDOW_H
#include <string>
#include <vector>
#include "Config.h"
#include "gui/interface/Point.h"
#include "Engine.h"
class Graphics;
namespace ui
{
@ -78,6 +80,10 @@ namespace ui
enum OkayMethod { Enter, OkayButton };
enum ExitMethod { MouseOutside, Escape, ExitButton };
void MakeActiveWindow();
bool CloseActiveWindow();
Graphics * GetGraphics();
protected:
ui::Button * okayButton;
ui::Button * cancelButton;

View File

@ -166,16 +166,15 @@ void LocalBrowserController::SetMoveToFront(bool move)
void LocalBrowserController::Exit()
{
if(ui::Engine::Ref().GetWindow() == browserView)
ui::Engine::Ref().CloseWindow();
browserView->CloseActiveWindow();
if(callback)
callback->ControllerExit();
HasDone = true;
}
LocalBrowserController::~LocalBrowserController() {
if(ui::Engine::Ref().GetWindow() == browserView)
ui::Engine::Ref().CloseWindow();
LocalBrowserController::~LocalBrowserController()
{
browserView->CloseActiveWindow();
delete callback;
delete browserModel;
delete browserView;

View File

@ -27,21 +27,16 @@ User LoginController::GetUser()
void LoginController::Exit()
{
if(ui::Engine::Ref().GetWindow() == loginView)
{
ui::Engine::Ref().CloseWindow();
}
loginView->CloseActiveWindow();
Client::Ref().SetAuthUser(loginModel->GetUser());
if(callback)
callback->ControllerExit();
HasExited = true;
}
LoginController::~LoginController() {
if(ui::Engine::Ref().GetWindow() == loginView)
{
ui::Engine::Ref().CloseWindow();
}
LoginController::~LoginController()
{
loginView->CloseActiveWindow();
delete loginModel;
delete loginView;
}

View File

@ -1,5 +1,6 @@
#include "LoginView.h"
#include "graphics/Graphics.h"
#include "gui/interface/Button.h"
#include "gui/interface/Label.h"
#include "gui/interface/Textbox.h"
@ -87,7 +88,7 @@ void LoginView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, boo
void LoginView::OnTryExit(ExitMethod method)
{
ui::Engine::Ref().CloseWindow();
CloseActiveWindow();
}
void LoginView::NotifyStatusChanged(LoginModel * sender)
@ -134,7 +135,7 @@ void LoginView::OnTick(float dt)
void LoginView::OnDraw()
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255);
}

View File

@ -1,5 +1,6 @@
#include "OptionsController.h"
#include "gui/dialogues/ErrorMessage.h"
#include "gui/interface/Engine.h"
OptionsController::OptionsController(GameModel * gModel_, ControllerCallback * callback_):
gModel(gModel_),
@ -93,10 +94,7 @@ OptionsView * OptionsController::GetView()
void OptionsController::Exit()
{
if (ui::Engine::Ref().GetWindow() == view)
{
ui::Engine::Ref().CloseWindow();
}
view->CloseActiveWindow();
// only update on close, it would be hard to edit if the changes were live
ui::Engine::Ref().Set3dDepth(depth3d);
if (callback)
@ -105,11 +103,9 @@ void OptionsController::Exit()
}
OptionsController::~OptionsController() {
if(ui::Engine::Ref().GetWindow() == view)
{
ui::Engine::Ref().CloseWindow();
}
OptionsController::~OptionsController()
{
view->CloseActiveWindow();
delete model;
delete view;
delete callback;

View File

@ -13,6 +13,7 @@
#include "gui/interface/Button.h"
#include "gui/interface/Label.h"
#include "gui/interface/DropDown.h"
#include "gui/interface/Engine.h"
#include "gui/dialogues/ErrorMessage.h"
OptionsView::OptionsView():
@ -297,7 +298,7 @@ void OptionsView::AttachController(OptionsController * c_)
void OptionsView::OnDraw()
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255);
g->draw_line(Position.X+1, Position.Y+scale->Position.Y-4, Position.X+Size.X-1, Position.Y+scale->Position.Y-4, 255, 255, 255, 180);

View File

@ -100,7 +100,7 @@ bool PreviewController::SubmitComment(std::string comment)
void PreviewController::ShowLogin()
{
loginWindow = new LoginController();
ui::Engine::Ref().ShowWindow(loginWindow->GetView());
loginWindow->GetView()->MakeActiveWindow();
}
void PreviewController::NotifyAuthUserChanged(Client * sender)
@ -181,20 +181,15 @@ bool PreviewController::PrevCommentPage()
void PreviewController::Exit()
{
if(ui::Engine::Ref().GetWindow() == previewView)
{
ui::Engine::Ref().CloseWindow();
}
previewView->CloseActiveWindow();
HasExited = true;
if(callback)
callback->ControllerExit();
}
PreviewController::~PreviewController() {
if(ui::Engine::Ref().GetWindow() == previewView)
{
ui::Engine::Ref().CloseWindow();
}
PreviewController::~PreviewController()
{
previewView->CloseActiveWindow();
Client::Ref().RemoveListener(this);
delete previewModel;
delete previewView;

View File

@ -329,7 +329,7 @@ void PreviewView::CheckComment()
void PreviewView::DoDraw()
{
Window::DoDraw();
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
for (size_t i = 0; i < commentTextComponents.size(); i++)
{
int linePos = commentTextComponents[i]->Position.Y+commentsPanel->ViewportPosition.Y+commentTextComponents[i]->Size.Y+4;
@ -353,7 +353,7 @@ void PreviewView::DoDraw()
void PreviewView::OnDraw()
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
//Window Background+Outline
g->clearrect(Position.X-2, Position.Y-2, Size.X+4, Size.Y+4);

View File

@ -263,7 +263,7 @@ void ProfileActivity::OnTick(float dt)
void ProfileActivity::OnDraw()
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255);
}

View File

@ -45,20 +45,15 @@ void RenderController::LoadRenderPreset(int presetNum)
void RenderController::Exit()
{
if(ui::Engine::Ref().GetWindow() == renderView)
{
ui::Engine::Ref().CloseWindow();
}
renderView->CloseActiveWindow();
if(callback)
callback->ControllerExit();
HasExited = true;
}
RenderController::~RenderController() {
if(ui::Engine::Ref().GetWindow() == renderView)
{
ui::Engine::Ref().CloseWindow();
}
RenderController::~RenderController()
{
renderView->CloseActiveWindow();
delete callback;
delete renderModel;
delete renderView;

View File

@ -1,4 +1,5 @@
#include "RenderModel.h"
#include "gui/game/RenderPreset.h"
RenderModel::RenderModel():
renderer(NULL)

View File

@ -365,7 +365,7 @@ void RenderView::NotifyColourChanged(RenderModel * sender)
void RenderView::OnDraw()
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
g->clearrect(-1, -1, WINDOWW+1, WINDOWH+1);
if(ren)
{

View File

@ -132,7 +132,7 @@ void LocalSaveActivity::saveWrite(std::string finalFilename)
void LocalSaveActivity::OnDraw()
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
g->draw_rgba_image(save_to_disk_image, 0, 0, 0.7f);
g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255);

View File

@ -1,4 +1,5 @@
#include "ServerSaveActivity.h"
#include "graphics/Graphics.h"
#include "gui/interface/Label.h"
#include "gui/interface/Textbox.h"
#include "gui/interface/Button.h"
@ -358,7 +359,7 @@ void ServerSaveActivity::OnTick(float dt)
void ServerSaveActivity::OnDraw()
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
g->draw_rgba_image(save_to_server_image, -10, 0, 0.7f);
g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255);

View File

@ -14,6 +14,7 @@ namespace ui
class Task;
class Thumbnail;
class VideoBuffer;
class ServerSaveActivity: public WindowActivity, public RequestListener, public TaskListener
{
public:

View File

@ -89,10 +89,7 @@ void SearchController::Update()
void SearchController::Exit()
{
InstantOpen(false);
if(ui::Engine::Ref().GetWindow() == searchView)
{
ui::Engine::Ref().CloseWindow();
}
searchView->CloseActiveWindow();
if(callback)
callback->ControllerExit();
//HasExited = true;
@ -101,10 +98,7 @@ void SearchController::Exit()
SearchController::~SearchController()
{
delete activePreview;
if(ui::Engine::Ref().GetWindow() == searchView)
{
ui::Engine::Ref().CloseWindow();
}
searchView->CloseActiveWindow();
delete searchModel;
delete searchView;
delete callback;
@ -209,19 +203,19 @@ void SearchController::InstantOpen(bool instant)
void SearchController::OpenSave(int saveID)
{
delete activePreview;
Graphics * g = ui::Engine::Ref().g;
Graphics * g = searchView->GetGraphics();
g->fillrect(XRES/3, WINDOWH-20, XRES/3, 20, 0, 0, 0, 150); //dim the "Page X of Y" a little to make the CopyTextButton more noticeable
activePreview = new PreviewController(saveID, instantOpen, new OpenCallback(this));
ui::Engine::Ref().ShowWindow(activePreview->GetView());
activePreview->GetView()->MakeActiveWindow();
}
void SearchController::OpenSave(int saveID, int saveDate)
{
delete activePreview;
Graphics * g = ui::Engine::Ref().g;
Graphics * g = searchView->GetGraphics();
g->fillrect(XRES/3, WINDOWH-20, XRES/3, 20, 0, 0, 0, 150); //dim the "Page X of Y" a little to make the CopyTextButton more noticeable
activePreview = new PreviewController(saveID, saveDate, instantOpen, new OpenCallback(this));
ui::Engine::Ref().ShowWindow(activePreview->GetView());
activePreview->GetView()->MakeActiveWindow();
}
void SearchController::ClearSelection()

View File

@ -35,16 +35,15 @@ void TagsController::AddTag(std::string tag)
void TagsController::Exit()
{
if(ui::Engine::Ref().GetWindow() == tagsView)
ui::Engine::Ref().CloseWindow();
tagsView->CloseActiveWindow();
if(callback)
callback->ControllerExit();
HasDone = true;
}
TagsController::~TagsController() {
if(ui::Engine::Ref().GetWindow() == tagsView)
ui::Engine::Ref().CloseWindow();
TagsController::~TagsController()
{
tagsView->CloseActiveWindow();
delete tagsModel;
delete tagsView;
delete callback;

View File

@ -1,6 +1,7 @@
#include "client/Client.h"
#include "TagsView.h"
#include "graphics/Graphics.h"
#include "gui/dialogues/ErrorMessage.h"
#include "TagsController.h"
#include "TagsModel.h"
@ -68,7 +69,7 @@ TagsView::TagsView():
void TagsView::OnDraw()
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255);
}

View File

@ -533,8 +533,8 @@ int LuaScriptInterface::interface_showWindow(lua_State * l)
int LuaScriptInterface::interface_closeWindow(lua_State * l)
{
LuaWindow * window = Luna<LuaWindow>::check(l, 1);
if(window && ui::Engine::Ref().GetWindow()==window->GetWindow())
ui::Engine::Ref().CloseWindow();
if (window)
window->GetWindow()->CloseActiveWindow();
return 0;
}

View File

@ -606,8 +606,7 @@ int LuaWindow::onKeyRelease(lua_State * l)
LuaWindow::~LuaWindow()
{
if(ui::Engine::Ref().GetWindow() == window)
ui::Engine::Ref().CloseWindow();
window->CloseActiveWindow();
delete window;
}
#endif

View File

@ -3,7 +3,7 @@
#include "common/tpt-thread.h"
#include "Config.h"
#include "Gravity.h"
//#include "powder.h"
#include "Misc.h"
void Gravity::bilinear_interpolation(float *src, float *dst, int sw, int sh, int rw, int rh)
{

View File

@ -1,7 +1,7 @@
#ifndef WALLTYPE_H_
#define WALLTYPE_H_
#include "graphics/Graphics.h"
#include "graphics/Pixel.h"
class VideoBuffer;
struct wall_type

View File

@ -1,13 +1,14 @@
#ifndef ELEMENTCLASS_H
#define ELEMENTCLASS_H
#include "graphics/Pixel.h"
#include "simulation/Simulation.h"
#include "graphics/Renderer.h"
#include "simulation/Elements.h"
#include "simulation/StructProperty.h"
class Simulation;
class Renderer;
class VideoBuffer;
struct Particle;
class Element
{

View File

@ -1,6 +1,7 @@
#include <sstream>
#include "common/tpt-minmax.h"
#include "gui/interface/Label.h"
#include "gui/interface/Engine.h"
#include "TaskWindow.h"
#include "gui/dialogues/ErrorMessage.h"
#include "gui/Style.h"
@ -27,7 +28,7 @@ TaskWindow::TaskWindow(std::string title_, Task * task_, bool closeOnDone):
statusLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(statusLabel);
ui::Engine::Ref().ShowWindow(this);
MakeActiveWindow();
task->AddTaskListener(this);
task->Start();
@ -53,9 +54,8 @@ void TaskWindow::NotifyDone(Task * task)
void TaskWindow::Exit()
{
if(ui::Engine::Ref().GetWindow()==this)
if (CloseActiveWindow())
{
ui::Engine::Ref().CloseWindow();
SelfDestruct();
}
}
@ -87,7 +87,7 @@ void TaskWindow::OnTick(float dt)
void TaskWindow::OnDraw()
{
Graphics * g = ui::Engine::Ref().g;
Graphics * g = GetGraphics();
g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255);