création de l'écran d'accueil
This commit is contained in:
parent
eb15fd6e21
commit
1e9d84e9af
|
@ -0,0 +1,37 @@
|
|||
#define BUTTON_HEIGHT 39
|
||||
#define TEXTURE_POSITION_BUTTON_NORMAL 132
|
||||
#define TEXTURE_POSITION_BUTTON_HIGHLIGHTED 172
|
||||
#define TEXTURE_POSITION_BUTTON_DESACTIVATED 92
|
||||
|
||||
#include <gint/display.h>
|
||||
|
||||
/* shows a button
|
||||
@state :
|
||||
0 : desactivated
|
||||
1 : normal
|
||||
2 : highlighted
|
||||
*/
|
||||
void show_button(int x, int y, int size, char const *text, bopti_image_t *img_widgets, int state) {
|
||||
if (size > 300) {
|
||||
size = 300;
|
||||
}
|
||||
|
||||
int texture_position = 0;
|
||||
|
||||
if (state == 0) {
|
||||
texture_position = TEXTURE_POSITION_BUTTON_DESACTIVATED;
|
||||
} else if (state == 1) {
|
||||
texture_position = TEXTURE_POSITION_BUTTON_NORMAL;
|
||||
} else {
|
||||
texture_position = TEXTURE_POSITION_BUTTON_HIGHLIGHTED;
|
||||
}
|
||||
|
||||
// left border
|
||||
dsubimage(x, y, img_widgets, 0, texture_position, 4, BUTTON_HEIGHT, 0x01);
|
||||
// middle
|
||||
dsubimage(x + 4, y, img_widgets, 4, texture_position, size - 8, BUTTON_HEIGHT, 0x01);
|
||||
// right border
|
||||
dsubimage(x + size - 4, y, img_widgets, 296, texture_position, 4, BUTTON_HEIGHT, 0x01);
|
||||
//text
|
||||
dtext_opt(x + (size / 2), y + (BUTTON_HEIGHT / 2) - 3, C_WHITE, -1, 1, 0, text, 14);
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef GUI_H
|
||||
#define GUI_H
|
||||
|
||||
/* shows a button
|
||||
@state :
|
||||
0 : desactivated
|
||||
1 : normal
|
||||
2 : highlighted
|
||||
*/
|
||||
void show_button(int x, int y, int size, char const *text, bopti_image_t *img_widgets, int state);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,65 @@
|
|||
#include <gint/display.h>
|
||||
#include <gint/keyboard.h>
|
||||
#include "gui.h"
|
||||
|
||||
void draw_menu(int selected)
|
||||
{
|
||||
//TODO : corriger le problème des string
|
||||
|
||||
extern bopti_image_t img_logo;
|
||||
extern bopti_image_t img_widgets;
|
||||
|
||||
//dclear(C_RGB(17,9,2));
|
||||
dclear(C_RGB(21,9,5));
|
||||
//dimage(72,20, &img_logo);
|
||||
dimage(40,10,&img_logo);
|
||||
|
||||
for(int i = 1; i <= 2; i++)
|
||||
{
|
||||
int x = 100;
|
||||
int y = 100 + 45*(i-1);
|
||||
char *text = "";
|
||||
|
||||
if (i==1)
|
||||
text = "Jouer";
|
||||
else
|
||||
text = "Paramètre";
|
||||
|
||||
if (i==selected)
|
||||
show_button(x, y, 200, text, &img_widgets, 2);
|
||||
else
|
||||
show_button(x, y, 200, text, &img_widgets, 1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
extern bopti_image_t img_widgets;
|
||||
|
||||
//dtext(1, 1, C_WHITE, "Sample fxSDK add-in.");
|
||||
|
||||
//dimage(40, 10, &img_widgets);
|
||||
show_button(100, 100, 200, "Jouer", &img_widgets, 1);
|
||||
dupdate();
|
||||
|
||||
int selected = 1;
|
||||
int key = 0;
|
||||
|
||||
while (key != KEY_EXE)
|
||||
{
|
||||
draw_menu(selected);
|
||||
dupdate();
|
||||
|
||||
key = getkey().key;
|
||||
|
||||
if (key == KEY_UP && selected == 2)
|
||||
selected--;
|
||||
if (key == KEY_DOWN && selected == 1)
|
||||
selected++;
|
||||
}
|
||||
|
||||
getkey();
|
||||
return 1;
|
||||
}
|
Loading…
Reference in New Issue