Some minor changes

This commit is contained in:
Simon Robertshaw 2012-01-17 20:46:06 +00:00
parent 6273089bf4
commit 4a60b97c70
167 changed files with 912 additions and 1055 deletions

View File

@ -1,22 +1,12 @@
HEADERS := $(wildcard includes/*.h)
HEADERS := $(wildcard src/*.h) $(wildcard src/*/*.h)
OLD_SOURCES := $(wildcard src/*.c)
OLD_OBJS := $(patsubst src/%.c,build/obj/%.o,$(OLD_SOURCES))
SOURCES := $(wildcard src/*.cpp) $(wildcard src/*/*.cpp)
OBJS += $(patsubst src/%.cpp,build/obj/powder.exe/%.o,$(SOURCES))
EL_SOURCES := $(wildcard elements/*.cpp)
EL_OBJS := $(patsubst elements/%.cpp,build/obj/elements/%.o,$(EL_SOURCES))
EL_PREREQ := $(patsubst build/obj/elements/%.o,build/obj/elements/%.powder.exe.o,$(EL_OBJS))
FOLDERS := $(sort $(dir $(OBJS)))
CORE_SOURCES := $(wildcard src/*.cpp)
CORE_OBJS := $(patsubst src/%.cpp,build/obj/core/%.o,$(CORE_SOURCES))
CORE_PREREQ := $(patsubst build/obj/core/%.o,build/obj/core/%.powder.exe.o,$(CORE_OBJS))
UI_SOURCES := $(wildcard src/interface/*.cpp)
UI_OBJS := $(patsubst src/interface/%.cpp,build/obj/ui/%.o,$(UI_SOURCES))
UI_PREREQ := $(patsubst build/obj/ui/%.o,build/obj/ui/%.powder.exe.o,$(UI_OBJS))
CFLAGS := -Iincludes/ -Idata/ -DWIN32 -DWINCONSOLE
OFLAGS := -fkeep-inline-functions #-O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations
CFLAGS := -Wno-deprecated -Wno-deprecated-declarations -Isrc/ -Idata/ -DWIN32 -DWINCONSOLE
OFLAGS := -O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations -msse2 -fkeep-inline-functions
LFLAGS := -lmingw32 -lregex -lws2_32 -lSDLmain -lpthread -lSDL -lm -lbz2 # -mwindows
CFLAGS += $(OFLAGS)
@ -28,14 +18,15 @@ WIN_RES := i686-w64-mingw32-windres
all: build/powder.exe
powder.exe: build/powder.exe
build/powder.exe: $(EL_PREREQ) $(CORE_PREREQ) $(UI_PREREQ)
$(CPPC) $(CFLAGS) $(LDFLAGS) $(EXTRA_OBJS) $(EL_PREREQ) $(CORE_PREREQ) $(UI_PREREQ) $(LFLAGS) -o $@ -ggdb
build/obj/ui/%.powder.exe.o: src/interface/%.cpp $(HEADERS)
$(CPPC) -c $(CFLAGS) -o $@ $< -ggdb
build/obj/elements/%.powder.exe.o: elements/%.cpp $(HEADERS)
$(CPPC) -c $(CFLAGS) -o $@ $< -ggdb
build/obj/core/%.powder.exe.o: src/%.cpp $(HEADERS)
build/powder.exe: buildpaths $(OBJS)
echo $(OBJS)
$(CPPC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LFLAGS) -o $@ -ggdb
build/obj/powder.exe/%.o: src/%.cpp $(HEADERS)
$(CPPC) -c $(CFLAGS) -o $@ $< -ggdb
buildpaths:
$(shell mkdir build/obj/powder.exe/)
$(shell mkdir $(FOLDERS))
clean:
rm build/obj/core/*.o

View File

@ -152,3 +152,159 @@ src/interface/Label.cpp
includes/interface/Label.h
includes/Global.h
src/Global.cpp
src/search/SearchModel.h
src/search/SearchModel.cpp
src/search/Save.h
src/search/SearchView.h
src/search/SearchView.cpp
src/search/SearchController.h
src/search/SearchController.cpp
src/game/GameController.h
src/game/GameController.cpp
src/game/GameModel.h
src/game/GameModel.cpp
src/interface/Window.h
src/interface/Window.cpp
src/game/GameView.h
src/game/GameView.cpp
src/Singleton.h
src/Simulation.h
src/Renderer.h
src/Misc.h
src/Gravity.h
src/Graphics.h
src/Global.h
src/Elements.h
src/ElementGraphics.h
src/ElementFunctions.h
src/Element.h
src/Console.h
src/Config.h
src/Air.h
src/Simulation.cpp
src/Renderer.cpp
src/PowderToy.cpp
src/Misc.cpp
src/Gravity.cpp
src/Graphics.cpp
src/Global.cpp
src/Console.cpp
src/Air.cpp
src/elements/yest.cpp
src/elements/wtrv.cpp
src/elements/wire.cpp
src/elements/wifi.cpp
src/elements/watr.cpp
src/elements/warp.cpp
src/elements/vine.cpp
src/elements/uran.cpp
src/elements/thrm.cpp
src/elements/thdr.cpp
src/elements/swch.cpp
src/elements/stor.cpp
src/elements/stkm2.cpp
src/elements/stkm.cpp
src/elements/sprk.cpp
src/elements/spng.cpp
src/elements/soap.cpp
src/elements/smke.cpp
src/elements/sltw.cpp
src/elements/sing.cpp
src/elements/shld.cpp
src/elements/rime.cpp
src/elements/qrtz.cpp
src/elements/pyro.cpp
src/elements/pvod.cpp
src/elements/pump.cpp
src/elements/prto.cpp
src/elements/prti.cpp
src/elements/plut.cpp
src/elements/plsm.cpp
src/elements/plnt.cpp
src/elements/pipe.cpp
src/elements/phot.cpp
src/elements/pcln.cpp
src/elements/pbcn.cpp
src/elements/O2.cpp
src/elements/nwhl.cpp
src/elements/nptct.cpp
src/elements/none.cpp
src/elements/newgraphics.cpp
src/elements/neut.cpp
src/elements/nbhl.cpp
src/elements/mort.cpp
src/elements/merc.cpp
src/elements/ligh.cpp
src/elements/legacy.cpp
src/elements/lcry.cpp
src/elements/lava.cpp
src/elements/isz.cpp
src/elements/iron.cpp
src/elements/ignt.cpp
src/elements/ice.cpp
src/elements/hswc.cpp
src/elements/h2.cpp
src/elements/graphics_default.cpp
src/elements/gpmp.cpp
src/elements/goo.cpp
src/elements/glow.cpp
src/elements/glas.cpp
src/elements/gbmb.cpp
src/elements/fwrk.cpp
src/elements/fuse.cpp
src/elements/fsep.cpp
src/elements/frzz.cpp
src/elements/frzw.cpp
src/elements/fog.cpp
src/elements/firw.cpp
src/elements/fire.cpp
src/elements/figh.cpp
src/elements/emp.cpp
src/elements/elementmisc.cpp
src/elements/elec.cpp
src/elements/dstw.cpp
src/elements/dlay.cpp
src/elements/deut.cpp
src/elements/dest.cpp
src/elements/conv.cpp
src/elements/coal.cpp
src/elements/co2.cpp
src/elements/clst.cpp
src/elements/clne.cpp
src/elements/cbnw.cpp
src/elements/caus.cpp
src/elements/c5.cpp
src/elements/btry.cpp
src/elements/brmt.cpp
src/elements/boyl.cpp
src/elements/bomb.cpp
src/elements/bmtl.cpp
src/elements/bizr.cpp
src/elements/bcol.cpp
src/elements/bcln.cpp
src/elements/bang.cpp
src/elements/aray.cpp
src/elements/anar.cpp
src/elements/amtr.cpp
src/elements/acid.cpp
src/elements/acel.cpp
src/interface/Window.h
src/interface/State.h
src/interface/Sandbox.h
src/interface/Point.h
src/interface/Platform.h
src/interface/Panel.h
src/interface/Label.h
src/interface/Engine.h
src/interface/ControlFactory.h
src/interface/Component.h
src/interface/Button.h
src/interface/Window.cpp
src/interface/State.cpp
src/interface/Sandbox.cpp
src/interface/Panel.cpp
src/interface/Label.cpp
src/interface/Engine.cpp
src/interface/ControlFactory.cpp
src/interface/Component.cpp
src/interface/Button.cpp

View File

View File

View File

@ -1,10 +0,0 @@
#ifndef GAMESESSION_H
#define GAMESESSION_H
class GameSession
{
public:
GameSession();
};
#endif // GAMESESSION_H

View File

@ -1,42 +0,0 @@
/*
* Button.h
*
* Created on: Jan 8, 2012
* Author: Simon
*/
#ifndef BUTTON_H_
#define BUTTON_H_
#include <string>
#include "Component.h"
namespace ui
{
class Button : public Component
{
public:
Button(int x, int y, int width, int height, const std::string& buttonText);
bool Toggleable;
std::string ButtonText;
virtual void OnMouseClick(int x, int y, unsigned int button);
virtual void OnMouseUnclick(int x, int y, unsigned int button);
virtual void OnMouseUp(int x, int y, unsigned int button);
virtual void OnMouseEnter(int x, int y, int dx, int dy);
virtual void OnMouseLeave(int x, int y, int dx, int dy);
virtual void Draw(void* userdata);
inline bool GetState() { return state; }
virtual void DoAction(); //action of button what ever it may be
protected:
bool isButtonDown, state, isMouseInside;
};
}
#endif /* BUTTON_H_ */

View File

@ -1,53 +0,0 @@
/*
* Component.h
*
* Created on: Jan 8, 2012
* Author: Simon
*/
#ifndef COMPONENT_H_
#define COMPONENT_H_
namespace ui
{
class State;
class Component
{
public:
Component(int x, int y, int width, int height);
virtual ~Component();
inline void LocalizePoint(int& x, int& y) { x -= X; y -= Y; } //convert a global point (point on the state) to a point based on component's position
inline void GlobalizePoint(int& x, int& y) { x += X; y += Y; } //convert a local point based on component's position to a global point on the state
bool Focused;
bool Visible;
bool Enabled;
int Width;
int Height;
int X;
int Y;
virtual void Tick(float dt);
virtual void Draw(void* userdata);
virtual void OnMouseEnter(int localx, int localy, int dx, int dy);
virtual void OnMouseLeave(int localx, int localy, int dx, int dy);
virtual void OnMouseMoved(int localx, int localy, int dx, int dy);
virtual void OnMouseMovedInside(int localx, int localy, int dx, int dy);
virtual void OnMouseHover(int localx, int localy);
virtual void OnMouseDown(int localx, int localy, unsigned int button);
virtual void OnMouseUp(int localx, int localy, unsigned int button);
virtual void OnMouseClick(int localx, int localy, unsigned int button);
virtual void OnMouseUnclick(int localx, int localy, unsigned int button);
virtual void OnMouseWheel(int localx, int localy, int d);
virtual void OnMouseWheelInside(int localx, int localy, int d);
virtual void OnMouseWheelFocused(int localx, int localy, int d);
virtual void OnKeyPress(int key, bool shift, bool ctrl, bool alt);
virtual void OnKeyRelease(int key, bool shift, bool ctrl, bool alt);
State* Parent;
};
}
#endif /* COMPONENT_H_ */

View File

@ -1,15 +0,0 @@
#ifndef CONTROLFACTORY_H
#define CONTROLFACTORY_H
#include "Panel.h"
#include "Window.h"
#include "GameSession.h"
class ControlFactory
{
public:
static ui::Panel * MainMenu(GameSession * session, int x, int y, int width, int height);
};
#endif // CONTROLFACTORY_H

View File

@ -1,22 +0,0 @@
/*
* Panel.h
*
* Created on: Jan 8, 2012
* Author: Simon
*/
#ifndef PANEL_H_
#define PANEL_H_
#include "interface/Component.h"
namespace ui {
class Panel: public ui::Component {
public:
Panel(int x, int y, int width, int height);
virtual ~Panel();
};
} /* namespace ui */
#endif /* PANEL_H_ */

View File

@ -1,36 +0,0 @@
/*
* Sandbox.h
*
* Created on: Jan 8, 2012
* Author: Simon
*/
#ifndef SANDBOX_H_
#define SANDBOX_H_
#include "Component.h"
#include "Simulation.h"
#include "Renderer.h"
namespace ui {
class Sandbox: public ui::Component {
private:
int lastCoordX, lastCoordY;
int activeElement;
bool isMouseDown;
Renderer * ren;
Simulation * sim;
public:
Sandbox();
virtual Simulation * GetSimulation();
virtual void OnMouseMovedInside(int localx, int localy, int dx, int dy);
virtual void OnMouseDown(int localx, int localy, unsigned int button);
virtual void OnMouseUp(int localx, int localy, unsigned int button);
virtual void Draw(void* userdata);
virtual void Tick(float delta);
virtual ~Sandbox();
};
} /* namespace ui */
#endif /* SANDBOX_H_ */

View File

@ -1,61 +0,0 @@
/*
* State.h
*
* Created on: Jan 8, 2012
* Author: Simon
*/
#ifndef STATE_H_
#define STATE_H_
#include <vector>
#include "interface/Component.h"
namespace ui {
class State
{
public:
State(int w, int h);
virtual ~State();
bool AllowExclusiveDrawing; //false will not call draw on objects outside of bounds
virtual void Tick(float dt);
virtual void Draw(void* userdata);
virtual void OnMouseMove(int x, int y);
virtual void OnMouseDown(int x, int y, unsigned int button);
virtual void OnMouseUp(int x, int y, unsigned int button);
virtual void OnMouseWheel(int x, int y, int d);
virtual void OnKeyPress(int key, bool shift, bool ctrl, bool alt);
virtual void OnKeyRelease(int key, bool shift, bool ctrl, bool alt);
virtual void Add(Component *child);
virtual void Remove(Component *child);
inline bool IsFocused(Component* c) { return (c == focusedComponent_); }
inline int GetMouseX() { return mouseX; }
inline int GetMouseY() { return mouseY; }
inline int GetWidth() { return width; }
inline int GetHeight() { return height; }
protected:
std::vector<Component*> Components;
int width;
int height;
int mouseX;
int mouseY;
int mouseXP;
int mouseYP;
private:
Component* focusedComponent_;
};
} /* namespace ui */
#endif /* STATE_H_ */

View File

@ -1,22 +0,0 @@
/*
* Window.h
*
* Created on: Jan 8, 2012
* Author: Simon
*/
#ifndef WINDOW_H_
#define WINDOW_H_
#include "interface/State.h"
namespace ui {
class Window: public ui::State {
public:
Window();
virtual ~Window();
};
} /* namespace ui */
#endif /* WINDOW_H_ */

View File

@ -1,51 +0,0 @@
/*
* Button.h
*
* Created on: Jan 8, 2012
* Author: Simon
*/
#ifndef BUTTON_H_
#define BUTTON_H_
#include <string>
#include "Component.h"
namespace ui
{
class Button : public Component
{
public:
Button(State* parent_state, std::string buttonText);
Button(Point position, Point size, std::string buttonText);
Button(std::string buttonText);
virtual ~Button();
bool Toggleable;
std::string ButtonText;
virtual void OnMouseClick(int x, int y, unsigned int button);
virtual void OnMouseUnclick(int x, int y, unsigned int button);
//virtual void OnMouseUp(int x, int y, unsigned int button);
virtual void OnMouseEnter(int x, int y);
virtual void OnMouseLeave(int x, int y);
virtual void Draw(const Point& screenPos);
inline bool GetState() { return state; }
virtual void DoAction(); //action of button what ever it may be
void SetTogglable(bool isTogglable);
bool GetTogglable();
inline bool GetToggleState();
inline void SetToggleState(bool state);
protected:
bool isButtonDown, state, isMouseInside, isTogglable, toggle;
};
}
#endif /* BUTTON_H_ */

View File

@ -1,6 +0,0 @@
#include "GameSession.h"
GameSession::GameSession()
{
//Boop
}

View File

@ -1,5 +1,6 @@
#include "Global.h"
/*#include "Global.h"
Global::Global(){
}
*/

View File

@ -4,11 +4,11 @@
#include "Singleton.h"
#include "Graphics.h"
class Global : public Singleton<Global>
/*class Global : public Singleton<Global>
{
public:
Graphics * g;
Global();
};
};*/
#endif // GAMESESSION_H

View File

@ -19,6 +19,9 @@
#include "interface/Point.h"
#include "interface/Label.h"
#include "game/GameController.h"
#include "game/GameView.h"
using namespace std;
SDL_Surface * SDLOpen()
@ -66,20 +69,24 @@ int main(int argc, char * argv[])
//Simulation * sim = new Simulation();
//ren = new Renderer(g, sim);
Global::Ref().g = new Graphics();
Global::Ref().g->AttachSDLSurface(SDLOpen());
ui::Engine::Ref().g = new Graphics();
ui::Engine::Ref().g->AttachSDLSurface(SDLOpen());
ui::Engine * engine = &ui::Engine::Ref();//new ui::Engine();
ui::State * engineState = new ui::State();
ui::Sandbox * sandbox = new ui::Sandbox();
ui::Button * button = new ui::Button(ui::Point(100, 100), ui::Point(100, 100), std::string("poP"));
//ui::State * engineState = new ui::State();
ui::Label * fpsLabel = new ui::Label(ui::Point(2, 2), ui::Point(200, 14), std::string("FPS: 0"));
//engineState->AddComponent(fpsLabel);
engine->Begin(XRES, YRES);
engine->SetState(engineState);
// engine->SetState(engineState);
GameController * gameController = new GameController();
engine->ShowWindow(gameController->GetView());
/*ui::Sandbox * sandbox = new ui::Sandbox();
ui::Button * button = new ui::Button(ui::Point(100, 100), ui::Point(100, 100), std::string("poP"));
engineState->AddComponent(fpsLabel);
engineState->AddComponent(sandbox);
engineState->AddComponent(button);
engineState->AddComponent(ControlFactory::MainMenu(0, YRES+MENUSIZE-17, XRES+BARSIZE, 16));
engineState->AddComponent(ControlFactory::MainMenu(0, YRES+MENUSIZE-17, XRES+BARSIZE, 16));*/
SDL_Event event;
while(engine->Running())

Some files were not shown because too many files have changed in this diff Show More