New background image.
This commit is contained in:
parent
fe10ae4e44
commit
bb60163798
|
@ -7,6 +7,6 @@ env = Environment(ENV = { 'TERM' : environ['TERM'] },
|
||||||
CPPPATH = 'src',
|
CPPPATH = 'src',
|
||||||
CXXFLAGS = flags,
|
CXXFLAGS = flags,
|
||||||
LINKFLAGS = flags,
|
LINKFLAGS = flags,
|
||||||
LIBS = ['SDL2', 'SDL2_ttf'])
|
LIBS = ['SDL2', 'SDL2_image', 'SDL2_ttf'])
|
||||||
|
|
||||||
env.Program('laines', Glob('src/*.cpp') + Glob('src/*/*.cpp'))
|
env.Program('laines', Glob('src/*.cpp') + Glob('src/*/*.cpp'))
|
||||||
|
|
BIN
res/init.bmp
BIN
res/init.bmp
Binary file not shown.
Before Width: | Height: | Size: 180 KiB |
BIN
res/init.png
Normal file
BIN
res/init.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 408 KiB |
10
src/gui.cpp
10
src/gui.cpp
|
@ -1,4 +1,5 @@
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
|
#include <SDL2/SDL_image.h>
|
||||||
#include <SDL2/SDL_ttf.h>
|
#include <SDL2/SDL_ttf.h>
|
||||||
#include "cartridge.hpp"
|
#include "cartridge.hpp"
|
||||||
#include "cpu.hpp"
|
#include "cpu.hpp"
|
||||||
|
@ -30,6 +31,7 @@ FileMenu* fileMenu;
|
||||||
|
|
||||||
bool pause = true;
|
bool pause = true;
|
||||||
|
|
||||||
|
// Controls settings:
|
||||||
SDL_Scancode CTRL_A = SDL_SCANCODE_A;
|
SDL_Scancode CTRL_A = SDL_SCANCODE_A;
|
||||||
SDL_Scancode CTRL_B = SDL_SCANCODE_S;
|
SDL_Scancode CTRL_B = SDL_SCANCODE_S;
|
||||||
SDL_Scancode CTRL_SELECT = SDL_SCANCODE_SPACE;
|
SDL_Scancode CTRL_SELECT = SDL_SCANCODE_SPACE;
|
||||||
|
@ -39,7 +41,6 @@ SDL_Scancode CTRL_DOWN = SDL_SCANCODE_DOWN;
|
||||||
SDL_Scancode CTRL_LEFT = SDL_SCANCODE_LEFT;
|
SDL_Scancode CTRL_LEFT = SDL_SCANCODE_LEFT;
|
||||||
SDL_Scancode CTRL_RIGHT = SDL_SCANCODE_RIGHT;
|
SDL_Scancode CTRL_RIGHT = SDL_SCANCODE_RIGHT;
|
||||||
|
|
||||||
|
|
||||||
/* Set the window size multiplier */
|
/* Set the window size multiplier */
|
||||||
void set_size(int mul)
|
void set_size(int mul)
|
||||||
{
|
{
|
||||||
|
@ -72,7 +73,7 @@ void init()
|
||||||
keys = SDL_GetKeyboardState(0);
|
keys = SDL_GetKeyboardState(0);
|
||||||
|
|
||||||
// Initial background:
|
// Initial background:
|
||||||
SDL_Surface* backSurface = SDL_LoadBMP("res/init.bmp");
|
SDL_Surface* backSurface = IMG_Load("res/init.png");
|
||||||
background = SDL_CreateTextureFromSurface(renderer, backSurface);
|
background = SDL_CreateTextureFromSurface(renderer, backSurface);
|
||||||
SDL_SetTextureColorMod(background, 60, 60, 60);
|
SDL_SetTextureColorMod(background, 60, 60, 60);
|
||||||
SDL_FreeSurface(backSurface);
|
SDL_FreeSurface(backSurface);
|
||||||
|
@ -191,10 +192,11 @@ void toggle_pause()
|
||||||
SDL_SetTextureColorMod(gameTexture, 255, 255, 255);
|
SDL_SetTextureColorMod(gameTexture, 255, 255, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Prompt for a key, return the scancode */
|
||||||
SDL_Scancode query_key()
|
SDL_Scancode query_key()
|
||||||
{
|
{
|
||||||
SDL_Texture* question = gen_text("Press a key...", { 255, 255, 255 });
|
SDL_Texture* prompt = gen_text("Press a key...", { 255, 255, 255 });
|
||||||
render_texture(question, TEXT_CENTER, height - fontSz*4);
|
render_texture(prompt, TEXT_CENTER, height - fontSz*4);
|
||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
|
|
||||||
SDL_Event e;
|
SDL_Event e;
|
||||||
|
|
35
src/menu.cpp
35
src/menu.cpp
|
@ -30,6 +30,11 @@ void Entry::setLabel(string label)
|
||||||
redTexture = gen_text(label, { 255, 0, 0 });
|
redTexture = gen_text(label, { 255, 0, 0 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Entry::render()
|
||||||
|
{
|
||||||
|
render_texture(selected ? redTexture : whiteTexture, getX(), getY());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ControlEntry::ControlEntry(string action, SDL_Scancode* key, int x, int y) : key(key),
|
ControlEntry::ControlEntry(string action, SDL_Scancode* key, int x, int y) : key(key),
|
||||||
Entry::Entry(
|
Entry::Entry(
|
||||||
|
@ -41,36 +46,6 @@ ControlEntry::ControlEntry(string action, SDL_Scancode* key, int x, int y) : key
|
||||||
this->keyEntry = new Entry(SDL_GetScancodeName(*key), []{}, TEXT_RIGHT, y);
|
this->keyEntry = new Entry(SDL_GetScancodeName(*key), []{}, TEXT_RIGHT, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlEntry::setY(int y)
|
|
||||||
{
|
|
||||||
Entry::setY(y);
|
|
||||||
this->keyEntry->setY(y);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ControlEntry::select()
|
|
||||||
{
|
|
||||||
Entry::select();
|
|
||||||
this->keyEntry->select();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ControlEntry::unselect()
|
|
||||||
{
|
|
||||||
Entry::unselect();
|
|
||||||
this->keyEntry->unselect();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ControlEntry::render()
|
|
||||||
{
|
|
||||||
Entry::render();
|
|
||||||
this->keyEntry->render();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Entry::render()
|
|
||||||
{
|
|
||||||
render_texture(selected ? redTexture : whiteTexture, getX(), getY());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Menu::add(Entry* entry)
|
void Menu::add(Entry* entry)
|
||||||
{
|
{
|
||||||
|
|
10
src/menu.hpp
10
src/menu.hpp
|
@ -31,7 +31,7 @@ class Entry
|
||||||
|
|
||||||
virtual void select() { selected = true; };
|
virtual void select() { selected = true; };
|
||||||
virtual void unselect() { selected = false; };
|
virtual void unselect() { selected = false; };
|
||||||
void trigger() { callback(); };
|
void trigger() { callback(); };
|
||||||
virtual void render();
|
virtual void render();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -42,10 +42,10 @@ class ControlEntry : public Entry
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ControlEntry(std::string action, SDL_Scancode* key, int x = 0, int y = 0);
|
ControlEntry(std::string action, SDL_Scancode* key, int x = 0, int y = 0);
|
||||||
void setY(int y);
|
void setY(int y) { Entry::setY(y); keyEntry->setY(y); }
|
||||||
void select();
|
void select() { Entry::select(); keyEntry->select(); }
|
||||||
void unselect();
|
void unselect() { Entry::unselect(); keyEntry->unselect(); }
|
||||||
void render();
|
void render() { Entry::render(); keyEntry->render(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class Menu
|
class Menu
|
||||||
|
|
Reference in a new issue