git repos / blockattack-game

blame: source/code/ShowFileState.cpp

normal view · raw

b7550ffe sago007 2018-05-19 10:08 1
/*
b7550ffe sago007 2018-05-19 10:08 2
===========================================================================
b7550ffe sago007 2018-05-19 10:08 3
blockattack - Block Attack - Rise of the Blocks
b7550ffe sago007 2018-05-19 10:08 4
Copyright (C) 2005-2018 Poul Sander
b7550ffe sago007 2018-05-19 10:08 5
This program is free software: you can redistribute it and/or modify
b7550ffe sago007 2018-05-19 10:08 6
it under the terms of the GNU General Public License as published by
b7550ffe sago007 2018-05-19 10:08 7
the Free Software Foundation, either version 2 of the License, or
b7550ffe sago007 2018-05-19 10:08 8
(at your option) any later version.
b7550ffe sago007 2018-05-19 10:08 9
This program is distributed in the hope that it will be useful,
b7550ffe sago007 2018-05-19 10:08 10
but WITHOUT ANY WARRANTY; without even the implied warranty of
b7550ffe sago007 2018-05-19 10:08 11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b7550ffe sago007 2018-05-19 10:08 12
GNU General Public License for more details.
b7550ffe sago007 2018-05-19 10:08 13
You should have received a copy of the GNU General Public License
b7550ffe sago007 2018-05-19 10:08 14
along with this program.  If not, see http://www.gnu.org/licenses/
b7550ffe sago007 2018-05-19 10:08 15
Source information and contacts persons can be found at
b7550ffe sago007 2018-05-19 10:08 16
https://blockattack.net
b7550ffe sago007 2018-05-19 10:08 17
===========================================================================
b7550ffe sago007 2018-05-19 10:08 18
*/
b7550ffe sago007 2018-05-19 10:08 19
d7f4a888 sago007 2020-06-28 09:22 20
#include "DialogBox.hpp"
46404443 sago007 2020-06-28 08:53 21
#include "HelpCommon.hpp"
b7550ffe sago007 2018-05-19 10:08 22
#include "ShowFileState.hpp"
b7550ffe sago007 2018-05-19 10:08 23
#include "global.hpp"
b7550ffe sago007 2018-05-19 10:08 24
#include "common.h"
b7550ffe sago007 2018-05-19 10:08 25
#include "MenuSystem.h"
16476649 Poul Sander 2022-01-09 10:29 26
#include <fmt/core.h>
b7550ffe sago007 2018-05-19 10:08 27
c2086a7e sago007 2018-05-19 14:16 28
static void setHelpGamepadFont(const sago::SagoDataHolder* holder, sago::SagoTextField& field, const char* text) {
c2086a7e sago007 2018-05-19 14:16 29
	field.SetHolder(holder);
c2086a7e sago007 2018-05-19 14:16 30
	field.SetFont("freeserif");
c2086a7e sago007 2018-05-19 14:16 31
	field.SetColor({255,255,255,255});
c2086a7e sago007 2018-05-19 14:16 32
	field.SetFontSize(30);
c2086a7e sago007 2018-05-19 14:16 33
	field.SetOutline(1, {128,128,128,255});
c2086a7e sago007 2018-05-19 14:16 34
	field.SetText(text);
c2086a7e sago007 2018-05-19 14:16 35
}
c2086a7e sago007 2018-05-19 14:16 36
b7550ffe sago007 2018-05-19 10:08 37
ShowFileState::ShowFileState() {
c2086a7e sago007 2018-05-19 14:16 38
	setHelpGamepadFont(&globalData.spriteHolder->GetDataHolder(), titleField, "");
46404443 sago007 2020-06-28 08:53 39
	setHelpBoxFont(&globalData.spriteHolder->GetDataHolder(), infoBox, "");
46404443 sago007 2020-06-28 08:53 40
	setHelpBoxFont(&globalData.spriteHolder->GetDataHolder(), filenameField, "");
b7550ffe sago007 2018-05-19 10:08 41
}
b7550ffe sago007 2018-05-19 10:08 42
b7550ffe sago007 2018-05-19 10:08 43
ShowFileState::~ShowFileState() {
b7550ffe sago007 2018-05-19 10:08 44
}
b7550ffe sago007 2018-05-19 10:08 45
16476649 Poul Sander 2022-01-09 10:29 46
void ShowFileState::SetData(const std::string& filename, const std::string& header) {
16476649 Poul Sander 2022-01-09 10:29 47
	titleField.SetText(header);
16476649 Poul Sander 2022-01-09 10:29 48
	infoBox.SetText(sago::GetFileContent(filename));
16476649 Poul Sander 2022-01-09 10:29 49
	filenameField.SetText(fmt::format(_("Showing content of: {}"), filename));
16476649 Poul Sander 2022-01-09 10:29 50
}
16476649 Poul Sander 2022-01-09 10:29 51
b7550ffe sago007 2018-05-19 10:08 52
void ShowFileState::Draw(SDL_Renderer* target) {
b7550ffe sago007 2018-05-19 10:08 53
	DrawBackground(target);
c2086a7e sago007 2018-05-19 14:16 54
	titleField.Draw(target, 50, 50);
c2086a7e sago007 2018-05-19 14:16 55
	DrawRectYellow(target, 40, 90, 600, 900);
c2086a7e sago007 2018-05-19 14:16 56
	infoBox.SetMaxWidth(850);
c2086a7e sago007 2018-05-19 14:16 57
	infoBox.Draw(target, 50, 100);
c2086a7e sago007 2018-05-19 14:16 58
	DrawRectYellow(target, 40, 700, 50, 900);
c2086a7e sago007 2018-05-19 14:16 59
	filenameField.Draw(target, 50, 715);
ec3f09de Poul Sander 2022-01-29 14:33 60
	HelpCommonState::Draw(target);
b7550ffe sago007 2018-05-19 10:08 61
}
b7550ffe sago007 2018-05-19 10:08 62
1970-01-01 00:00 63