-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
127 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. | ||
* If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* | ||
* This Source Code Form is "Incompatible With Secondary Licenses", | ||
* as defined by the Mozilla Public License, v. 2.0. | ||
*/ | ||
|
||
#include "serverview.hpp" | ||
|
||
ServerView::ServerView() : Context(ContextName::ROOM_LIST), | ||
btn_back("Logout"), btn_newRoom("Create room"), btn_goToShop("Item shop"), | ||
btn_addFriend("Add friend"), btn_prevPage("<"), btn_nextPage(">"), | ||
in_addFriend("Add friend", "Enter player id") { | ||
|
||
|
||
addWidgets(); | ||
} | ||
|
||
ServerView::~ServerView() { | ||
// Cleanup our surfaces | ||
if (background) { | ||
SDL_FreeSurface(background); | ||
} | ||
if (backTexture) { | ||
SDL_DestroyTexture(backTexture); | ||
} | ||
} | ||
|
||
void ServerView::action(const gcn::ActionEvent& actionEvent) { | ||
|
||
} | ||
|
||
void ServerView::addWidgets() { | ||
|
||
int xStep = getWidth() / 5; | ||
addWidget(&btn_back, xStep - btn_back.getWidth(), getHeight() - 2 * btn_back.getHeight()); | ||
addWidget(&btn_newRoom, 2 *xStep - btn_newRoom.getWidth(), btn_back.getY()); | ||
addWidget(&btn_goToShop, 3 * xStep - btn_goToShop.getWidth(), btn_back.getY()); | ||
addWidget(&btn_addFriend, 4 * xStep - btn_addFriend.getWidth(), btn_back.getY()); | ||
} | ||
|
||
void ServerView::drawBackground(SDL_Renderer* screen) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. | ||
* If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* | ||
* This Source Code Form is "Incompatible With Secondary Licenses", | ||
* as defined by the Mozilla Public License, v. 2.0. | ||
*/ | ||
|
||
#ifndef _H_SERVERVIEW_ | ||
#define _H_SERVERVIEW_ | ||
|
||
#include <map> | ||
#include <guisan.hpp> | ||
#include "../context.hpp" | ||
|
||
class ServerView final : public Context, public gcn::ActionListener { | ||
public: | ||
ServerView(); | ||
virtual ~ServerView(); | ||
|
||
virtual void drawBackground(SDL_Renderer* screen) override; | ||
virtual void drawOverlay(SDL_Renderer* screen) override { | ||
// No overlays in ServerView | ||
}; | ||
virtual void processEvent(SDL_Event& event) override { | ||
// No specific handling to be done here, GUI handles everything | ||
}; | ||
// Inherited via ActionListener | ||
void action(const gcn::ActionEvent& actionEvent) override; | ||
|
||
private: | ||
gcn::Button btn_back; | ||
gcn::Button btn_newRoom; | ||
gcn::Button btn_goToShop; | ||
gcn::Button btn_addFriend; | ||
|
||
gcn::Button btn_prevPage; | ||
gcn::Button btn_nextPage; | ||
|
||
gcn::Label lbl_playerName; | ||
gcn::Label lbl_playerTeam; | ||
gcn::Label lbl_playerPoints; | ||
gcn::Label lbl_playerMoney; | ||
|
||
gcn::Label lbl_pages; | ||
|
||
gcn::TextBox tb_chat; | ||
gcn::ScrollArea sa_chat; | ||
gcn::TextField tf_message; | ||
|
||
gcn::InputBox in_addFriend; | ||
|
||
SDL_Texture* backTexture = nullptr; | ||
SDL_Surface* background = nullptr; | ||
SDL_Texture* playerLvlTexture = nullptr; | ||
|
||
void addWidgets(); | ||
}; | ||
|
||
#endif // !_H_SERVERVIEW_ |