Permalink
Browse files

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
  • Loading branch information...
jacob1 committed Jul 14, 2017
1 parent 781a90a commit 5ee10d14e413a4e5c564ccfdd5965cc60c1231fa
Showing with 307 additions and 270 deletions.
  1. +2 −8 src/Activity.h
  2. +1 −2 src/debug/DebugLines.cpp
  3. +2 −1 src/debug/DebugParts.cpp
  4. +2 −92 src/graphics/Graphics.h
  5. +46 −0 src/graphics/Icons.h
  6. +53 −0 src/graphics/Pixel.h
  7. +2 −0 src/graphics/Renderer.cpp
  8. +1 −3 src/graphics/Renderer.h
  9. +1 −1 src/gui/colourpicker/ColourPickerActivity.cpp
  10. +6 −8 src/gui/console/ConsoleController.cpp
  11. +1 −1 src/gui/console/ConsoleView.cpp
  12. +7 −6 src/gui/dialogues/ConfirmPrompt.cpp
  13. +1 −0 src/gui/dialogues/ConfirmPrompt.h
  14. +4 −3 src/gui/dialogues/ErrorMessage.cpp
  15. +4 −3 src/gui/dialogues/InformationMessage.cpp
  16. +5 −4 src/gui/dialogues/SaveIDMessage.cpp
  17. +4 −3 src/gui/dialogues/TextPrompt.cpp
  18. +1 −1 src/gui/elementsearch/ElementSearchActivity.cpp
  19. +1 −1 src/gui/filebrowser/FileBrowserActivity.cpp
  20. +5 −8 src/gui/game/GameController.cpp
  21. +1 −0 src/gui/game/GameModel.h
  22. +2 −2 src/gui/game/GameView.cpp
  23. +7 −6 src/gui/game/PropertyTool.cpp
  24. +6 −6 src/gui/game/SignTool.cpp
  25. +2 −1 src/gui/game/ToolButton.cpp
  26. +1 −0 src/gui/interface/Appearance.cpp
  27. +2 −1 src/gui/interface/Appearance.h
  28. +1 −2 src/gui/interface/AvatarButton.cpp
  29. +2 −2 src/gui/interface/Button.cpp
  30. +3 −1 src/gui/interface/Checkbox.cpp
  31. +6 −0 src/gui/interface/Component.cpp
  32. +4 −1 src/gui/interface/Component.h
  33. +7 −5 src/gui/interface/ContextMenu.cpp
  34. +1 −0 src/gui/interface/CopyTextButton.cpp
  35. +7 −5 src/gui/interface/DropDown.cpp
  36. +3 −1 src/gui/interface/Label.cpp
  37. +0 −1 src/gui/interface/Label.h
  38. +1 −1 src/gui/interface/Panel.cpp
  39. +1 −0 src/gui/interface/Panel.h
  40. +2 −1 src/gui/interface/ProgressBar.cpp
  41. +1 −1 src/gui/interface/RichLabel.cpp
  42. +1 −2 src/gui/interface/SaveButton.cpp
  43. +2 −1 src/gui/interface/ScrollPanel.cpp
  44. +2 −1 src/gui/interface/Slider.cpp
  45. +2 −1 src/gui/interface/Spinner.cpp
  46. +3 −2 src/gui/interface/Textbox.cpp
  47. +22 −0 src/gui/interface/Window.cpp
  48. +7 −1 src/gui/interface/Window.h
  49. +4 −5 src/gui/localbrowser/LocalBrowserController.cpp
  50. +4 −9 src/gui/login/LoginController.cpp
  51. +3 −2 src/gui/login/LoginView.cpp
  52. +5 −9 src/gui/options/OptionsController.cpp
  53. +2 −1 src/gui/options/OptionsView.cpp
  54. +5 −10 src/gui/preview/PreviewController.cpp
  55. +2 −2 src/gui/preview/PreviewView.cpp
  56. +1 −1 src/gui/profile/ProfileActivity.cpp
  57. +4 −9 src/gui/render/RenderController.cpp
  58. +1 −0 src/gui/render/RenderModel.cpp
  59. +1 −1 src/gui/render/RenderView.cpp
  60. +1 −1 src/gui/save/LocalSaveActivity.cpp
  61. +2 −1 src/gui/save/ServerSaveActivity.cpp
  62. +1 −0 src/gui/save/ServerSaveActivity.h
  63. +6 −12 src/gui/search/SearchController.cpp
  64. +4 −5 src/gui/tags/TagsController.cpp
  65. +2 −1 src/gui/tags/TagsView.cpp
  66. +2 −2 src/lua/LuaScriptInterface.cpp
  67. +1 −2 src/lua/LuaWindow.cpp
  68. +1 −1 src/simulation/Gravity.cpp
  69. +1 −1 src/simulation/WallType.h
  70. +2 −1 src/simulation/elements/Element.h
  71. +4 −4 src/tasks/TaskWindow.cpp
@@ -26,17 +26,11 @@ class WindowActivity: public ui::Window, public Activity
}
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() {}
};
@@ -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())
{
@@ -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),
@@ -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
@@ -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
@@ -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
@@ -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"
@@ -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
@@ -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);
@@ -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;
@@ -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);
@@ -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);
@@ -1,6 +1,7 @@
#ifndef CONFIRMPROMPT_H_
#define CONFIRMPROMPT_H_
#include <string>
#include "gui/interface/Window.h"
class ConfirmDialogueCallback;
Oops, something went wrong.

0 comments on commit 5ee10d1

Please sign in to comment.