git repos / blockattack-game

blame: source/code/HelpGamepadState.cpp

normal view · raw

54d2d583 sago007 2018-04-05 17:52 1
/*
54d2d583 sago007 2018-04-05 17:52 2
===========================================================================
54d2d583 sago007 2018-04-05 17:52 3
blockattack - Block Attack - Rise of the Blocks
54d2d583 sago007 2018-04-05 17:52 4
Copyright (C) 2005-2018 Poul Sander
54d2d583 sago007 2018-04-05 17:52 5
54d2d583 sago007 2018-04-05 17:52 6
This program is free software: you can redistribute it and/or modify
54d2d583 sago007 2018-04-05 17:52 7
it under the terms of the GNU General Public License as published by
54d2d583 sago007 2018-04-05 17:52 8
the Free Software Foundation, either version 2 of the License, or
54d2d583 sago007 2018-04-05 17:52 9
(at your option) any later version.
54d2d583 sago007 2018-04-05 17:52 10
54d2d583 sago007 2018-04-05 17:52 11
This program is distributed in the hope that it will be useful,
54d2d583 sago007 2018-04-05 17:52 12
but WITHOUT ANY WARRANTY; without even the implied warranty of
54d2d583 sago007 2018-04-05 17:52 13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
54d2d583 sago007 2018-04-05 17:52 14
GNU General Public License for more details.
54d2d583 sago007 2018-04-05 17:52 15
54d2d583 sago007 2018-04-05 17:52 16
You should have received a copy of the GNU General Public License
54d2d583 sago007 2018-04-05 17:52 17
along with this program.  If not, see http://www.gnu.org/licenses/
54d2d583 sago007 2018-04-05 17:52 18
54d2d583 sago007 2018-04-05 17:52 19
Source information and contacts persons can be found at
54d2d583 sago007 2018-04-05 17:52 20
https://blockattack.net
54d2d583 sago007 2018-04-05 17:52 21
===========================================================================
54d2d583 sago007 2018-04-05 17:52 22
*/
54d2d583 sago007 2018-04-05 17:52 23
54d2d583 sago007 2018-04-05 17:52 24
#include "HelpGamepadState.hpp"
54d2d583 sago007 2018-04-05 17:52 25
#include "global.hpp"
54d2d583 sago007 2018-04-05 17:52 26
#include "common.h"
54d2d583 sago007 2018-04-05 17:52 27
#include "MenuSystem.h"
54d2d583 sago007 2018-04-05 17:52 28
54d2d583 sago007 2018-04-05 17:52 29
HelpGamepadState::HelpGamepadState() {
492b2753 sago007 2018-04-07 14:37 30
	moveLabel.SetHolder(&globalData.spriteHolder->GetDataHolder());
492b2753 sago007 2018-04-07 14:37 31
	moveLabel.SetFontSize(30);
492b2753 sago007 2018-04-07 14:37 32
	moveLabel.SetOutline(1, {128,128,128,255});
492b2753 sago007 2018-04-07 14:37 33
	moveLabel.SetText(_("Move cursor"));
492b2753 sago007 2018-04-07 14:37 34
	pushLabel.SetHolder(&globalData.spriteHolder->GetDataHolder());
492b2753 sago007 2018-04-07 14:37 35
	pushLabel.SetFontSize(30);
492b2753 sago007 2018-04-07 14:37 36
	pushLabel.SetOutline(1, {128,128,128,255});
492b2753 sago007 2018-04-07 14:37 37
	pushLabel.SetText(_("Push line"));
54d2d583 sago007 2018-04-05 17:52 38
}
54d2d583 sago007 2018-04-05 17:52 39
54d2d583 sago007 2018-04-05 17:52 40
54d2d583 sago007 2018-04-05 17:52 41
HelpGamepadState::~HelpGamepadState() {
54d2d583 sago007 2018-04-05 17:52 42
}
54d2d583 sago007 2018-04-05 17:52 43
54d2d583 sago007 2018-04-05 17:52 44
bool HelpGamepadState::IsActive() {
54d2d583 sago007 2018-04-05 17:52 45
	return isActive;
54d2d583 sago007 2018-04-05 17:52 46
}
54d2d583 sago007 2018-04-05 17:52 47
54d2d583 sago007 2018-04-05 17:52 48
void HelpGamepadState::ProcessInput(const SDL_Event& event, bool& processed) {
54d2d583 sago007 2018-04-05 17:52 49
	UpdateMouseCoordinates(event, globalData.mousex, globalData.mousey);
54d2d583 sago007 2018-04-05 17:52 50
54d2d583 sago007 2018-04-05 17:52 51
	if (isConfirmEvent(event) || isEscapeEvent(event)) {
54d2d583 sago007 2018-04-05 17:52 52
		isActive = false;
54d2d583 sago007 2018-04-05 17:52 53
		processed = true;
54d2d583 sago007 2018-04-05 17:52 54
	}
54d2d583 sago007 2018-04-05 17:52 55
}
54d2d583 sago007 2018-04-05 17:52 56
54d2d583 sago007 2018-04-05 17:52 57
void HelpGamepadState::Draw(SDL_Renderer* target) {
54d2d583 sago007 2018-04-05 17:52 58
	DrawBackground(target);
a5421912 sago007 2018-04-07 14:13 59
	const sago::SagoSprite& gamepad = globalData.spriteHolder->GetSprite("help_controller");
a5421912 sago007 2018-04-07 14:13 60
	gamepad.Draw(target, SDL_GetTicks(), globalData.xsize/2-480/2, 100);
492b2753 sago007 2018-04-07 14:37 61
	SDL_RenderDrawLine(target, 100, 210, globalData.xsize/2-480/2+130, 210);
492b2753 sago007 2018-04-07 14:37 62
	SDL_RenderDrawLine(target, 100, 298, globalData.xsize/2-480/2+158, 298);
492b2753 sago007 2018-04-07 14:37 63
	SDL_RenderDrawLine(target, 100, 210, 100, 400);
492b2753 sago007 2018-04-07 14:37 64
	moveLabel.Draw(target, 100, 404, sago::SagoTextField::Alignment::center);
492b2753 sago007 2018-04-07 14:37 65
	SDL_RenderDrawLine(target, globalData.xsize/2-480/2+140, 90, globalData.xsize/2-480/2+140, 105);
492b2753 sago007 2018-04-07 14:37 66
	SDL_RenderDrawLine(target, globalData.xsize/2+480/2-140, 90, globalData.xsize/2+480/2-140, 105);
492b2753 sago007 2018-04-07 14:37 67
	SDL_RenderDrawLine(target, globalData.xsize/2-480/2+140, 90, globalData.xsize/2+480/2-140, 90);
492b2753 sago007 2018-04-07 14:37 68
	SDL_RenderDrawLine(target, globalData.xsize/2, 80, globalData.xsize/2, 90);
492b2753 sago007 2018-04-07 14:37 69
	pushLabel.Draw(target, globalData.xsize/2, 80, sago::SagoTextField::Alignment::center, sago::SagoTextField::VerticalAlignment::bottom);
54d2d583 sago007 2018-04-05 17:52 70
}
54d2d583 sago007 2018-04-05 17:52 71
54d2d583 sago007 2018-04-05 17:52 72
void HelpGamepadState::Update() {
54d2d583 sago007 2018-04-05 17:52 73
	
54d2d583 sago007 2018-04-05 17:52 74
}