OnScreenKeyboard: Creado el esqueleto base
This commit is contained in:
24
main.cpp
24
main.cpp
@@ -15,6 +15,7 @@ Código fuente creado por JailDesigner
|
|||||||
#include "units/texture.h"
|
#include "units/texture.h"
|
||||||
#include "units/screen.h"
|
#include "units/screen.h"
|
||||||
#include "units/input.h"
|
#include "units/input.h"
|
||||||
|
#include "units/on_screen_keyboard.h"
|
||||||
#include "quickcg.h"
|
#include "quickcg.h"
|
||||||
using namespace QuickCG;
|
using namespace QuickCG;
|
||||||
|
|
||||||
@@ -32,6 +33,7 @@ Text *text;
|
|||||||
Text *debugText;
|
Text *debugText;
|
||||||
Texture *texture;
|
Texture *texture;
|
||||||
MovingSprite *sprite;
|
MovingSprite *sprite;
|
||||||
|
OnScreenKeyboard *osk;
|
||||||
|
|
||||||
// Variables de uso general
|
// Variables de uso general
|
||||||
Uint32 ticks = 0; // Variable para la frecuencia de actualización de la lógica del programa
|
Uint32 ticks = 0; // Variable para la frecuencia de actualización de la lógica del programa
|
||||||
@@ -90,6 +92,9 @@ void initInput();
|
|||||||
// Inicializa el texto
|
// Inicializa el texto
|
||||||
void initText();
|
void initText();
|
||||||
|
|
||||||
|
// Inicializa el teclado en pantalla
|
||||||
|
void initOnScreenKeyboard();
|
||||||
|
|
||||||
// Inicializa el sprite
|
// Inicializa el sprite
|
||||||
void initSprite();
|
void initSprite();
|
||||||
|
|
||||||
@@ -235,6 +240,12 @@ void initText()
|
|||||||
debugText = new Text(asset->get("debug.txt"), asset->get("debug.png"), renderer);
|
debugText = new Text(asset->get("debug.txt"), asset->get("debug.png"), renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inicializa el teclado en pantalla
|
||||||
|
void initOnScreenKeyboard()
|
||||||
|
{
|
||||||
|
osk = new OnScreenKeyboard(renderer, input, asset->get("notify.png"), asset->get("smb2.png"), asset->get("smb2.txt"), options);
|
||||||
|
}
|
||||||
|
|
||||||
// Inicializa el sprite
|
// Inicializa el sprite
|
||||||
void initSprite()
|
void initSprite()
|
||||||
{
|
{
|
||||||
@@ -312,6 +323,9 @@ void initAll(char *argv[])
|
|||||||
// Inicializa el texto
|
// Inicializa el texto
|
||||||
initText();
|
initText();
|
||||||
|
|
||||||
|
// Inicializa el teclado en pantalla
|
||||||
|
initOnScreenKeyboard();
|
||||||
|
|
||||||
// Inicializa el sprite
|
// Inicializa el sprite
|
||||||
initSprite();
|
initSprite();
|
||||||
|
|
||||||
@@ -514,7 +528,8 @@ void update()
|
|||||||
// Incrementa el contador
|
// Incrementa el contador
|
||||||
counter++;
|
counter++;
|
||||||
|
|
||||||
// Actualiza el objeto screen
|
// Actualiza los objetos
|
||||||
|
osk->update();
|
||||||
screen->update();
|
screen->update();
|
||||||
|
|
||||||
// Actualiza el sprite
|
// Actualiza el sprite
|
||||||
@@ -608,6 +623,9 @@ void render()
|
|||||||
// Dinuja el texto
|
// Dinuja el texto
|
||||||
renderText();
|
renderText();
|
||||||
|
|
||||||
|
// Dibuja el teclado en pantalla
|
||||||
|
osk->render();
|
||||||
|
|
||||||
// Vuelca el buffer en pantalla
|
// Vuelca el buffer en pantalla
|
||||||
screen->blit();
|
screen->blit();
|
||||||
}
|
}
|
||||||
@@ -621,6 +639,10 @@ void freeAll()
|
|||||||
if (texture != nullptr)
|
if (texture != nullptr)
|
||||||
delete texture;
|
delete texture;
|
||||||
|
|
||||||
|
// Finaliza el teclado en pantalla
|
||||||
|
if (osk != nullptr)
|
||||||
|
delete osk;
|
||||||
|
|
||||||
// Finaliza el texto
|
// Finaliza el texto
|
||||||
if (text != nullptr)
|
if (text != nullptr)
|
||||||
delete text;
|
delete text;
|
||||||
|
|||||||
43
units/on_screen_keyboard.cpp
Normal file
43
units/on_screen_keyboard.cpp
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#include "on_screen_keyboard.h"
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
OnScreenKeyboard::OnScreenKeyboard(SDL_Renderer *renderer, Input *input, string iconFile, string bitmapFile, string textFile, options_t *options)
|
||||||
|
{
|
||||||
|
// Inicializa variables
|
||||||
|
this->renderer = renderer;
|
||||||
|
this->options = options;
|
||||||
|
this->input = input;
|
||||||
|
|
||||||
|
// Crea objetos
|
||||||
|
iconTexture = new Texture(renderer, iconFile);
|
||||||
|
text = new Text(textFile, bitmapFile, renderer);
|
||||||
|
|
||||||
|
// Inicializa variables
|
||||||
|
letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
OnScreenKeyboard::~OnScreenKeyboard()
|
||||||
|
{
|
||||||
|
// Libera la memoria de los objetos
|
||||||
|
if (iconTexture != nullptr)
|
||||||
|
{
|
||||||
|
delete iconTexture;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (text != nullptr)
|
||||||
|
{
|
||||||
|
delete text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actualiza la lógica del objeto
|
||||||
|
void OnScreenKeyboard::update()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dibuja el objeto en pantalla
|
||||||
|
void OnScreenKeyboard::render()
|
||||||
|
{
|
||||||
|
text->write(0,0,"ON_SCREEN_KEYBOARD");
|
||||||
|
}
|
||||||
43
units/on_screen_keyboard.h
Normal file
43
units/on_screen_keyboard.h
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include "utils.h"
|
||||||
|
#include "text.h"
|
||||||
|
#include "input.h"
|
||||||
|
|
||||||
|
#ifndef ON_SCREEN_KEYBOARD_H
|
||||||
|
#define ON_SCREEN_KEYBOARD_H
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
class OnScreenKeyboard
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Objetos y punteros
|
||||||
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
|
Texture *iconTexture; // Textura para los gráficos
|
||||||
|
Text *text; // Objeto para dibujar texto
|
||||||
|
Input *input; // Gestor de eventos de entrada de teclado o gamepad
|
||||||
|
options_t *options; // Variable con todas las opciones del programa
|
||||||
|
|
||||||
|
// Variables
|
||||||
|
string letters;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
OnScreenKeyboard(SDL_Renderer *renderer, Input *input, string iconFile, string bitmapFile, string textFile, options_t *options);
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
~OnScreenKeyboard();
|
||||||
|
|
||||||
|
// Actualiza la lógica del objeto
|
||||||
|
void update();
|
||||||
|
|
||||||
|
// Dibuja el objeto en pantalla
|
||||||
|
void render();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user