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
b7550ffe sago007 2018-05-19 10:08 28
ShowFileState::ShowFileState() {
dfebdcd4 Poul Sander 2022-01-30 18:12 29
	setHelp30FontThinOutline(&globalData.spriteHolder->GetDataHolder(), titleField, "");
46404443 sago007 2020-06-28 08:53 30
	setHelpBoxFont(&globalData.spriteHolder->GetDataHolder(), infoBox, "");
46404443 sago007 2020-06-28 08:53 31
	setHelpBoxFont(&globalData.spriteHolder->GetDataHolder(), filenameField, "");
b7550ffe sago007 2018-05-19 10:08 32
}
b7550ffe sago007 2018-05-19 10:08 33
b7550ffe sago007 2018-05-19 10:08 34
ShowFileState::~ShowFileState() {
b7550ffe sago007 2018-05-19 10:08 35
}
b7550ffe sago007 2018-05-19 10:08 36
16476649 Poul Sander 2022-01-09 10:29 37
void ShowFileState::SetData(const std::string& filename, const std::string& header) {
16476649 Poul Sander 2022-01-09 10:29 38
	titleField.SetText(header);
16476649 Poul Sander 2022-01-09 10:29 39
	infoBox.SetText(sago::GetFileContent(filename));
16476649 Poul Sander 2022-01-09 10:29 40
	filenameField.SetText(fmt::format(_("Showing content of: {}"), filename));
16476649 Poul Sander 2022-01-09 10:29 41
}
16476649 Poul Sander 2022-01-09 10:29 42
b7550ffe sago007 2018-05-19 10:08 43
void ShowFileState::Draw(SDL_Renderer* target) {
b7550ffe sago007 2018-05-19 10:08 44
	DrawBackground(target);
c2086a7e sago007 2018-05-19 14:16 45
	titleField.Draw(target, 50, 50);
c2086a7e sago007 2018-05-19 14:16 46
	DrawRectYellow(target, 40, 90, 600, 900);
c2086a7e sago007 2018-05-19 14:16 47
	infoBox.SetMaxWidth(850);
c2086a7e sago007 2018-05-19 14:16 48
	infoBox.Draw(target, 50, 100);
c2086a7e sago007 2018-05-19 14:16 49
	DrawRectYellow(target, 40, 700, 50, 900);
c2086a7e sago007 2018-05-19 14:16 50
	filenameField.Draw(target, 50, 715);
ec3f09de Poul Sander 2022-01-29 14:33 51
	HelpCommonState::Draw(target);
b7550ffe sago007 2018-05-19 10:08 52
}
b7550ffe sago007 2018-05-19 10:08 53
1970-01-01 00:00 54