Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2c19792

Browse files
author
Thumperrr
committedFeb 24, 2013
Merge pull request #12 from Thumperrr/master
Framework overhaul
2 parents 01adfd1 + 1a8e1a3 commit 2c19792

13 files changed

+231
-427
lines changed
 

‎src/AppState.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef _APPSTATE_H
22
#define _APPSTATE_H
3+
34
#include "SFMLEvent.h"
5+
#include <SFML/Graphics.hpp>
46

57
namespace chesspp
68
{
@@ -11,12 +13,12 @@ namespace chesspp
1113
AppState() {}
1214
virtual ~AppState() {}
1315

14-
virtual void onActivate() = 0;
15-
void onEvent(sf::Event *Event) { SFMLEvent::OnEvent(Event); }
16-
virtual void onLoop() = 0;
17-
virtual void onRender(sf::RenderWindow *display) = 0;
18-
virtual void onDeactivate() = 0;
16+
virtual int id() = 0;
17+
virtual void OnRender(sf::RenderWindow &display) = 0;
1918
};
2019
}
2120

21+
#include "AppStateGame.h"
22+
/* Convenience header inclusion so we don't have to include each individual inheritor */
23+
2224
#endif

‎src/AppStateGame.cpp

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,18 @@
1-
#include "AppStateGame.h"
1+
#include "AppState.h"
22

33
namespace chesspp
44
{
5-
void AppStateGame::onRender(sf::RenderWindow *display)
5+
int AppStateGame::id() { return 1; }
6+
7+
void AppStateGame::OnRender(sf::RenderWindow &display)
68
{
7-
display->draw(sf::Sprite(TextureManager::getInstance().Load("../res/img/chessboard_640x640.png")));
8-
}
9-
10-
void AppStateGame::onLoop()
11-
{
12-
13-
}
14-
15-
void AppStateGame::onActivate()
16-
{
17-
#ifdef _DEBUG
18-
cout << "AppStateGame activated." << endl; //<--- placeholder for proof of concept
19-
#endif // _DEBUG
20-
}
21-
22-
void AppStateGame::onDeactivate()
23-
{
24-
#ifdef _DEBUG
25-
cout << "AppStateGame deactivated." << endl; //<--- placeholder for proof of concept
26-
#endif // _DEBUG
9+
display.draw(sf::Sprite(TextureManager::getInstance().Load("../res/img/chessboard_640x640.png")));
2710
}
2811

2912
void AppStateGame::OnLButtonPressed(int x, int y)
3013
{
3114
#ifdef _DEBUG
32-
cout << "Left button clicked." << endl;
15+
cout << "Left clicked at (" << x << ", " << y << ")\n";
3316
#endif // _DEBUG
34-
}
17+
}
3518
}

‎src/AppStateGame.h

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#define _APPSTATEGAME_H
33
#include "SFML.hpp"
44
#include "TextureManager.h"
5-
#include "AppState.h"
65

76
#ifdef _DEBUG
87
#include <iostream>
@@ -11,29 +10,19 @@
1110

1211
namespace chesspp
1312
{
13+
class Application;
1414
class AppStateGame : public AppState
1515
{
16+
Application* app;
17+
1618
public:
17-
AppStateGame(const AppStateGame&);
18-
AppStateGame() {}
19-
~AppStateGame() {}
19+
AppStateGame(Application* _app) : app(_app) {}
20+
virtual ~AppStateGame() {}
21+
22+
virtual int id();
23+
virtual void OnRender(sf::RenderWindow &display);
2024

21-
static AppStateGame *getInstance() //singleton class
22-
{
23-
static AppStateGame instance;
24-
return &instance;
25-
}
26-
27-
void onActivate();
28-
void onLoop();
29-
void onRender(sf::RenderWindow *display);
30-
void onDeactivate();
31-
32-
//Event handler example. SFMLEvent interface redirects certain events into function calls.
33-
virtual void OnLButtonPressed(int x, int y);
34-
35-
private:
36-
//members of game can go here, board, etc etc.
25+
virtual void OnLButtonPressed(int x, int y); //example implementation
3726
};
3827
}
3928

‎src/AppStateManager.cpp

Lines changed: 0 additions & 42 deletions
This file was deleted.

‎src/AppStateManager.h

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.