Commit 4a21a689 authored by Michael Ochmann's avatar Michael Ochmann
Browse files

finished credits state; not finally, though ...

parent b3d02321
......@@ -9,15 +9,46 @@
"width" : 100,
"childs" : [
{
"type" : "textured",
"id" : "creditsBackdrop",
"background" : "ui/backdrop/Komp 1_00001.png",
"frametime" : 0.07,
"x" : 0,
"y" : 0,
"height" : 100,
"width" : "auto",
"childs" : []
"type" : "animation",
"id" : "creditsBackdrop",
"frames" : [
"ui/backdrop/Komp 1_00000.png",
"ui/backdrop/Komp 1_00001.png",
"ui/backdrop/Komp 1_00002.png",
"ui/backdrop/Komp 1_00003.png",
"ui/backdrop/Komp 1_00004.png",
"ui/backdrop/Komp 1_00005.png",
"ui/backdrop/Komp 1_00006.png",
"ui/backdrop/Komp 1_00007.png",
"ui/backdrop/Komp 1_00008.png",
"ui/backdrop/Komp 1_00009.png",
"ui/backdrop/Komp 1_00010.png",
"ui/backdrop/Komp 1_00011.png",
"ui/backdrop/Komp 1_00012.png",
"ui/backdrop/Komp 1_00013.png",
"ui/backdrop/Komp 1_00014.png",
"ui/backdrop/Komp 1_00015.png",
"ui/backdrop/Komp 1_00016.png",
"ui/backdrop/Komp 1_00017.png",
"ui/backdrop/Komp 1_00018.png",
"ui/backdrop/Komp 1_00019.png",
"ui/backdrop/Komp 1_00020.png",
"ui/backdrop/Komp 1_00021.png",
"ui/backdrop/Komp 1_00022.png",
"ui/backdrop/Komp 1_00023.png",
"ui/backdrop/Komp 1_00024.png",
"ui/backdrop/Komp 1_00025.png",
"ui/backdrop/Komp 1_00026.png",
"ui/backdrop/Komp 1_00027.png",
"ui/backdrop/Komp 1_00028.png",
"ui/backdrop/Komp 1_00029.png"
],
"frametime" : 0.07,
"x" : 0,
"y" : 0,
"height" : 100,
"width" : "auto",
"childs" : []
},
{
"type" : "box",
......
......@@ -2,36 +2,38 @@
{
"title" : "Gameplay",
"members" : [
"Benjamin Barz",
"Elias Broschin",
"Jeremias Boos"
"Tim Grundmanns",
"Johannes Kirchner",
"Sabrina Katharina Kotzem"
]
},
{
"title" : "Gameplay",
"title" : "Input",
"members" : [
"Elias Broschin",
"Jeremias Boos"
"Benjamin Albsmeier"
]
},
{
"title" : "Gameplay",
"title" : "UI",
"members" : [
"Elias Broschin",
"Jeremias Boos"
"Jeremias Boos",
"Thomas Eppers",
"Michael Ochmann"
]
},
{
"title" : "Gameplay",
"title" : "Rendering",
"members" : [
"Elias Broschin",
"Jeremias Boos"
"Fabio Gimmillaro",
"Georg Schäfer"
]
},
{
"title" : "Gameplay",
"title" : "Sound",
"members" : [
"Elias Broschin",
"Jeremias Boos"
"Michael Ochmann"
]
}
]
\ No newline at end of file
......@@ -14,35 +14,34 @@
"frames" : [
"ui/backdrop/Komp 1_00000.png",
"ui/backdrop/Komp 1_00001.png",
"ui/backdrop/Komp 1_00002.png"
//,
//"ui/backdrop/Komp 1_00003.png",
//"ui/backdrop/Komp 1_00004.png",
//"ui/backdrop/Komp 1_00005.png",
//"ui/backdrop/Komp 1_00006.png",
//"ui/backdrop/Komp 1_00007.png",
//"ui/backdrop/Komp 1_00008.png",
//"ui/backdrop/Komp 1_00009.png",
//"ui/backdrop/Komp 1_00010.png",
//"ui/backdrop/Komp 1_00011.png",
//"ui/backdrop/Komp 1_00012.png",
//"ui/backdrop/Komp 1_00013.png",
//"ui/backdrop/Komp 1_00014.png",
//"ui/backdrop/Komp 1_00015.png",
//"ui/backdrop/Komp 1_00016.png",
//"ui/backdrop/Komp 1_00017.png",
//"ui/backdrop/Komp 1_00018.png",
//"ui/backdrop/Komp 1_00019.png",
//"ui/backdrop/Komp 1_00020.png",
//"ui/backdrop/Komp 1_00021.png",
//"ui/backdrop/Komp 1_00022.png",
//"ui/backdrop/Komp 1_00023.png",
//"ui/backdrop/Komp 1_00024.png",
//"ui/backdrop/Komp 1_00025.png",
//"ui/backdrop/Komp 1_00026.png",
//"ui/backdrop/Komp 1_00027.png",
//"ui/backdrop/Komp 1_00028.png",
//"ui/backdrop/Komp 1_00029.png"
"ui/backdrop/Komp 1_00002.png",
"ui/backdrop/Komp 1_00003.png",
"ui/backdrop/Komp 1_00004.png",
"ui/backdrop/Komp 1_00005.png",
"ui/backdrop/Komp 1_00006.png",
"ui/backdrop/Komp 1_00007.png",
"ui/backdrop/Komp 1_00008.png",
"ui/backdrop/Komp 1_00009.png",
"ui/backdrop/Komp 1_00010.png",
"ui/backdrop/Komp 1_00011.png",
"ui/backdrop/Komp 1_00012.png",
"ui/backdrop/Komp 1_00013.png",
"ui/backdrop/Komp 1_00014.png",
"ui/backdrop/Komp 1_00015.png",
"ui/backdrop/Komp 1_00016.png",
"ui/backdrop/Komp 1_00017.png",
"ui/backdrop/Komp 1_00018.png",
"ui/backdrop/Komp 1_00019.png",
"ui/backdrop/Komp 1_00020.png",
"ui/backdrop/Komp 1_00021.png",
"ui/backdrop/Komp 1_00022.png",
"ui/backdrop/Komp 1_00023.png",
"ui/backdrop/Komp 1_00024.png",
"ui/backdrop/Komp 1_00025.png",
"ui/backdrop/Komp 1_00026.png",
"ui/backdrop/Komp 1_00027.png",
"ui/backdrop/Komp 1_00028.png",
"ui/backdrop/Komp 1_00029.png"
],
"frametime" : 0.07,
"x" : 0,
......
......@@ -3,10 +3,20 @@
#include <game_state_machine/game_state.h>
#include <ui/text_widget.hpp>
#include <util/jsoncpp.hpp>
namespace gdw {
class credits_state : public game_state {
private:
ui_widget* rootElement;
Json::Value dom;
float topMargin;
void loadContent();
text_widget* generateHeader(std::string text);
text_widget* generateText(std::string text);
public:
credits_state(engine& engine);
~credits_state();
......
......@@ -12,6 +12,7 @@
#include <game_state_machine/play_state.h>
#include <ui/ui_system.hpp>
#include <ui/UIManager.hpp>
#include <graphics/graphics_system.hpp>
#include <ui/text_widget.hpp>
#include <util/fsi.hpp>
#include <util/jsoncpp.hpp>
......@@ -20,43 +21,23 @@
namespace gdw {
credits_state::credits_state(engine &engine):game_state(engine) {
credits_state::credits_state(engine &engine) :
game_state(engine),
topMargin(0.5f/100*5) {
id_ = type_id<credits_state>();
this->uiManager = make_unique<gdw::UIManager>(this->engine_, "ui/credits.json");
auto file = this->engine_.asset_manager().load("ui/creditsText.json");
if (!file) {
log(log_level::error) << "Could not load UI file 'creditsText'" << std::endl;
}
this->loadContent();
Json::Value dom;
Json::Reader reader;
if (!reader.parse(&(*file->content().begin()), &(*file->content().end()), dom))
log << "error loading jsonz" << std::endl;
text_widget* screen = (text_widget*) this->uiManager->getElementById("scroll");
this->engine_.ui_system().loadFont("font/FreebooterUpdated.ttf");
int top = 1;
float oldY = 0;
for (auto &widget : dom) {
text_widget* test = (text_widget*) screen->add_widget<text_widget>(25/100.f,top*5/100.f + oldY,100/100.f,100/100.f,"FreebooterUpdated",
widget["title"].asString(),
80, fsi::hexToVec4("000000FF"),
NVG_ALIGN_CENTER|NVG_ALIGN_MIDDLE
);
oldY += top*5/100.f;
int top2 = 1;
for (auto &widget : this->dom) {
this->topMargin += 5/100.f;
text_widget* header = this->generateHeader(widget["title"].asString());
this->topMargin += 5/100.f;
log << this->topMargin/100.f << std::endl;
for (Json::Value::iterator it = widget["members"].begin(); it != widget["members"].end(); ++it) {
screen->add_widget<text_widget>(25/100.f,
(test->y() + test->height() + oldY + top2 * 2)/100.f,
100/100.f,100/100.f,"FreebooterUpdated",
(*it).asString(),
50, fsi::hexToVec4("000000FF"),
NVG_ALIGN_CENTER|NVG_ALIGN_MIDDLE
);
oldY +=top2 * 2;
top2++;
text_widget* line = this->generateText((*it).asString());
this->topMargin += 4/100.f;
}
top++;
}
}
......@@ -69,11 +50,53 @@ namespace gdw {
void credits_state::update(float dt) {
if (this->engine_.input().isPressed(inputMapping::state_switch))
this->engine_.game_state_machine().change_state<menu_state>();
//this->uiManager->getElementById("scroll")->y(this->uiManager->getElementById("scroll")->y() - 0.001);
if (this->rootElement->y_px() <= (this->rootElement->height_px() + this->engine_.graphics_system().height()) * -1) {
this->rootElement->y(this->uiManager->getElementById("credits")->height());
this->topMargin = 0.5f/100*5;
}
this->rootElement->y(this->rootElement->y() - 0.001);
}
void credits_state::on_exit() {
this->uiManager->render(false);
}
text_widget* credits_state::generateHeader(std::string text) {
this->rootElement->add_widget<text_widget>(
25/100.f,
this->topMargin,
100/100.f,100/100.f,
"FreebooterUpdated",
text,
80, fsi::hexToVec4("000000FF"),
NVG_ALIGN_CENTER|NVG_ALIGN_MIDDLE
);
}
text_widget* credits_state::generateText(std::string text) {
this->rootElement->add_widget<text_widget>(
25/100.f,
this->topMargin,
100/100.f,
100/100.f,
"FreebooterUpdated",
text,
50,
fsi::hexToVec4("000000FF"),
NVG_ALIGN_CENTER|NVG_ALIGN_MIDDLE
);
}
void credits_state::loadContent() {
this->engine_.ui_system().loadFont("font/FreebooterUpdated.ttf");
auto file = this->engine_.asset_manager().load("ui/creditsText.json");
if (!file) {
log(log_level::error) << "Could not load UI file 'creditsText'" << std::endl;
}
Json::Reader reader;
if (!reader.parse(&(*file->content().begin()), &(*file->content().end()), this->dom))
log << "error loading json" << std::endl;
this->rootElement = (text_widget*) this->uiManager->getElementById("scroll");
}
} //namespace gdw
......@@ -66,8 +66,6 @@ void menu_state::update(float dt) {
button2->color(fsi::hexToVec4("000000FF"));
text_widget* button3 = (text_widget*) this->uiManager->getElementById("quit");
button3->color(fsi::hexToVec4("000000FF"));
if (this->engine_.input().isPressed(inputMapping::state_switch))
this->engine_.game_state_machine().change_state<play_state>();
}
void menu_state::on_exit() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment