added a menu aiming at managing all the available options
This commit is contained in:
parent
db45c8e839
commit
f3d581bcf5
|
@ -35,6 +35,8 @@ set(ASSETS_cg
|
|||
assets-cg/fontlabel.png
|
||||
assets-cg/bglens.png
|
||||
assets-cg/tile.png
|
||||
|
||||
assets-cg/OptionBox.png
|
||||
)
|
||||
|
||||
fxconv_declare_assets(${ASSETS_cg} WITH_METADATA)
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 558 B |
|
@ -21,4 +21,9 @@ bglens.png:
|
|||
tile.png:
|
||||
type: bopti-image
|
||||
profile: p8
|
||||
name: tilerotozoom
|
||||
name: tilerotozoom
|
||||
|
||||
OptionBox.png:
|
||||
type: bopti-image
|
||||
profile: p8_rgb565a
|
||||
name: optionbox
|
31
src/config.h
31
src/config.h
|
@ -4,8 +4,35 @@
|
|||
|
||||
#define MAXHEIGHT 224
|
||||
|
||||
#define SWITCH_DELAY 30
|
||||
|
||||
#define MORE_RAM 0
|
||||
|
||||
|
||||
|
||||
/* usual colors*/
|
||||
#define RGB565_BLACK 0x0000
|
||||
#define RGB565_RED 0xF800
|
||||
#define RGB565_GREEN 0x07E0
|
||||
#define RGB565_BLUE 0x001F
|
||||
#define RGB565_YELLOW 0xFFE0
|
||||
#define RGB565_PURPLE 0xF81F
|
||||
#define RGB565_CYAN 0x07FF
|
||||
#define RGB565_WHITE 0xFFFF
|
||||
|
||||
/* advanced palette */
|
||||
#define RGB565_DARKORANGE 0xF280
|
||||
#define RGB565_ORANGE 0xF4A0
|
||||
#define RGB565_LIGHORANGE 0xF5C0
|
||||
|
||||
#define RGB565_LEMONYELLOW 0xF7C6
|
||||
#define RGB565_APPLEGREEN 0xCF25
|
||||
#define RGB565_LEAFGREEN 0x6566
|
||||
|
||||
#define RGB565_OCEANBLUE 0x0479
|
||||
#define RGB565_AZURBLUE 0x023E
|
||||
#define RGB565_DEEPBLUE 0x3813
|
||||
|
||||
#define RGB565_DEEPPURPLE 0x8015
|
||||
#define RGB565_CHERRYRED 0xA0C9
|
||||
#define RGB565_BLOODYRED 0xF122
|
||||
|
||||
#endif
|
||||
|
|
220
src/main.cpp
220
src/main.cpp
|
@ -58,12 +58,18 @@ bool screenshot = false;
|
|||
bool record = false;
|
||||
bool showFPS = false;
|
||||
bool showName = true;
|
||||
bool showOption = false;
|
||||
bool EffectLoop = true;
|
||||
|
||||
uint8_t MenuOptionSelected = 1;
|
||||
|
||||
bool choosePrevious = false;
|
||||
bool chooseNext = false;
|
||||
int reverse = false;
|
||||
float timeSinceLastEffect = 0.0f;
|
||||
|
||||
uint8_t effect_duration_seconds = 20;
|
||||
|
||||
KeyboardExtra Keyboard;
|
||||
|
||||
|
||||
|
@ -83,6 +89,13 @@ uint8_t imagedata[DWIDTH*MAXHEIGHT];
|
|||
|
||||
|
||||
|
||||
static void Initialise( void );
|
||||
static void Update( void );
|
||||
static void Render( void );
|
||||
static void Close( void );
|
||||
|
||||
|
||||
|
||||
int get_pixel(bopti_image_t const *img, int x, int y)
|
||||
{
|
||||
return image_get_pixel(img, x, y);
|
||||
|
@ -169,43 +182,14 @@ void FreeMoreRAM( void )
|
|||
#endif
|
||||
}
|
||||
|
||||
static void Initialise( void )
|
||||
{
|
||||
(*Effects_Init[ current_effect ])( screen );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void Render( void )
|
||||
{
|
||||
(*Effects_Render[ current_effect ])( screen );
|
||||
|
||||
if (showName)
|
||||
{
|
||||
dfont( &font_label );
|
||||
dprint( 10, 205, C_WHITE, "%s", (*Effect_Text[current_effect])() );
|
||||
}
|
||||
}
|
||||
|
||||
static void Update( [[maybe_unused]] float dt )
|
||||
{
|
||||
(*Effects_Update[ current_effect ])( screen, dt );
|
||||
}
|
||||
|
||||
static void Close( void )
|
||||
{
|
||||
(*Effects_DeInit[ current_effect ])( screen );
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void GetInputs( [[maybe_unused]] float dt )
|
||||
{
|
||||
if (Keyboard.IsKeyPressed(MYKEY_EXIT)) {exitToOS = true; };
|
||||
|
||||
if (Keyboard.IsKeyPressedEvent(MYKEY_F3)) showFPS = !showFPS;
|
||||
if (Keyboard.IsKeyPressedEvent(MYKEY_F4)) showName = !showName;
|
||||
//if (Keyboard.IsKeyPressedEvent(MYKEY_F3)) showFPS = !showFPS;
|
||||
//if (Keyboard.IsKeyPressedEvent(MYKEY_F4)) showName = !showName;
|
||||
if (Keyboard.IsKeyPressedEvent(MYKEY_OPTN)) showOption = !showOption;
|
||||
|
||||
if ((Keyboard.IsKeyPressedEvent(MYKEY_F1) || choosePrevious) && current_effect>=1)
|
||||
{
|
||||
|
@ -236,6 +220,134 @@ static void GetInputs( [[maybe_unused]] float dt )
|
|||
}
|
||||
}
|
||||
|
||||
static void GetInputsOption( [[maybe_unused]] float dt )
|
||||
{
|
||||
//if (Keyboard.IsKeyPressed(MYKEY_EXIT)) {exitToOS = true; };
|
||||
|
||||
if (Keyboard.IsKeyPressedEvent(MYKEY_OPTN)) showOption = !showOption;
|
||||
|
||||
if (Keyboard.IsKeyPressedEvent(MYKEY_UP))
|
||||
{
|
||||
MenuOptionSelected--;
|
||||
if (MenuOptionSelected==0) MenuOptionSelected=4;
|
||||
}
|
||||
|
||||
if (Keyboard.IsKeyPressedEvent(MYKEY_DOWN))
|
||||
{
|
||||
MenuOptionSelected++;
|
||||
if (MenuOptionSelected==5) MenuOptionSelected=1;
|
||||
}
|
||||
|
||||
if (Keyboard.IsKeyPressedEvent(MYKEY_LEFT))
|
||||
{
|
||||
switch(MenuOptionSelected)
|
||||
{
|
||||
case 1:
|
||||
showFPS = !showFPS;
|
||||
break;
|
||||
case 2:
|
||||
showName = !showName;
|
||||
break;
|
||||
case 3:
|
||||
EffectLoop = !EffectLoop;
|
||||
break;
|
||||
case 4:
|
||||
effect_duration_seconds--;
|
||||
if (effect_duration_seconds<5) effect_duration_seconds=5;
|
||||
}
|
||||
}
|
||||
|
||||
if (Keyboard.IsKeyPressedEvent(MYKEY_RIGHT))
|
||||
{
|
||||
switch(MenuOptionSelected)
|
||||
{
|
||||
case 1:
|
||||
showFPS = !showFPS;
|
||||
break;
|
||||
case 2:
|
||||
showName = !showName;
|
||||
break;
|
||||
case 3:
|
||||
EffectLoop = !EffectLoop;
|
||||
break;
|
||||
case 4:
|
||||
effect_duration_seconds++;
|
||||
if (effect_duration_seconds>30) effect_duration_seconds=30;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void Initialise( void )
|
||||
{
|
||||
(*Effects_Init[ current_effect ])( screen );
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void ShowOptionBox( void )
|
||||
{
|
||||
extern bopti_image_t optionbox;
|
||||
|
||||
uint16_t w = optionbox.width;
|
||||
uint16_t h = optionbox.height;
|
||||
|
||||
dimage( (DWIDTH-w)/2, (MAXHEIGHT-h)/2, &optionbox );
|
||||
|
||||
dfont( &font_label );
|
||||
|
||||
dprint( (DWIDTH-w)/2 +26, (MAXHEIGHT-h)/2 +6, C_RED, "Show FPS : %s", showFPS == true ? "< Yes >" : "< No >" );
|
||||
dprint( (DWIDTH-w)/2 +25, (MAXHEIGHT-h)/2 +5, MenuOptionSelected==1 ? RGB565_LEMONYELLOW : RGB565_WHITE, "Show FPS : %s", showFPS == true ? "< Yes >" : "< No >" );
|
||||
|
||||
dprint( (DWIDTH-w)/2 +26, (MAXHEIGHT-h)/2 +26, C_RED, "Effect Name : %s", showName == true ? "< Yes >" : "< No >" );
|
||||
dprint( (DWIDTH-w)/2 +25, (MAXHEIGHT-h)/2 +25, MenuOptionSelected==2 ? RGB565_LEMONYELLOW : RGB565_WHITE, "Effect Name : %s", showName == true ? "< Yes >" : "< No >" );
|
||||
|
||||
dprint( (DWIDTH-w)/2 +26, (MAXHEIGHT-h)/2 +46, C_RED, "Cycling : %s", EffectLoop == false ? "< Autoreverse >" : "< Loop >" );
|
||||
dprint( (DWIDTH-w)/2 +25, (MAXHEIGHT-h)/2 +45, MenuOptionSelected==3 ? RGB565_LEMONYELLOW : RGB565_WHITE, "Cycling : %s", EffectLoop == false ? "< Autoreverse >" : "< Loop >" );
|
||||
|
||||
dprint( (DWIDTH-w)/2 +26, (MAXHEIGHT-h)/2 +66, C_RED, "Effect Duration : < %d s >", effect_duration_seconds );
|
||||
dprint( (DWIDTH-w)/2 +25, (MAXHEIGHT-h)/2 +65, MenuOptionSelected==4 ? RGB565_LEMONYELLOW : RGB565_WHITE, "Effect Duration : < %d s >", effect_duration_seconds );
|
||||
}
|
||||
|
||||
|
||||
static void Render( void )
|
||||
{
|
||||
(*Effects_Render[ current_effect ])( screen );
|
||||
|
||||
if(showFPS)
|
||||
{
|
||||
dfont( &font_label );
|
||||
dprint( 11, 6, C_RED, "Framerate : %.0f FPS", (float) (1000000.0f/elapsedTime) );
|
||||
dprint( 10, 5, C_WHITE, "Framerate : %.0f FPS", (float) (1000000.0f/elapsedTime) );
|
||||
}
|
||||
|
||||
if (showName)
|
||||
{
|
||||
dfont( &font_label );
|
||||
dprint( 11, 206, C_RED, "%s", (*Effect_Text[current_effect])() );
|
||||
dprint( 10, 205, C_WHITE, "%s", (*Effect_Text[current_effect])() );
|
||||
}
|
||||
|
||||
if(showOption)
|
||||
{
|
||||
ShowOptionBox();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void Update( [[maybe_unused]] float dt )
|
||||
{
|
||||
(*Effects_Update[ current_effect ])( screen, dt );
|
||||
}
|
||||
|
||||
|
||||
static void Close( void )
|
||||
{
|
||||
(*Effects_DeInit[ current_effect ])( screen );
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(void)
|
||||
|
@ -277,7 +389,8 @@ int main(void)
|
|||
Keyboard.Update( elapsedTime );
|
||||
|
||||
// read inputs from the player
|
||||
GetInputs( elapsedTime );
|
||||
if (!showOption) GetInputs( elapsedTime );
|
||||
else GetInputsOption( elapsedTime );
|
||||
|
||||
// update as per the time spend to do the loop
|
||||
Update( elapsedTime );
|
||||
|
@ -296,10 +409,7 @@ int main(void)
|
|||
{
|
||||
// Call the render functions
|
||||
Render();
|
||||
|
||||
dfont( nullptr );
|
||||
if(showFPS) dprint(1,1, C_WHITE, "FPS %.0f", (float) (1000000.0f/elapsedTime) );
|
||||
|
||||
|
||||
dupdate();
|
||||
}
|
||||
prof_leave(perf_render);
|
||||
|
@ -308,24 +418,38 @@ int main(void)
|
|||
elapsedTime = ((float) (time_update+time_render));
|
||||
|
||||
timeSinceLastEffect += elapsedTime / 1000000.0f;
|
||||
if (timeSinceLastEffect >= SWITCH_DELAY)
|
||||
if (timeSinceLastEffect >= effect_duration_seconds)
|
||||
{
|
||||
if(!reverse)
|
||||
if(EffectLoop)
|
||||
{
|
||||
if(current_effect<TOTAL_NB_EFFECT-1) chooseNext=true;
|
||||
else
|
||||
{
|
||||
reverse = true;
|
||||
choosePrevious = true;
|
||||
}
|
||||
Close();
|
||||
|
||||
current_effect++;
|
||||
current_effect = current_effect % TOTAL_NB_EFFECT;
|
||||
|
||||
timeSinceLastEffect = 0.0f;
|
||||
|
||||
Initialise();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(current_effect>0) choosePrevious=true;
|
||||
if(!reverse)
|
||||
{
|
||||
if(current_effect<TOTAL_NB_EFFECT-1) chooseNext=true;
|
||||
else
|
||||
{
|
||||
reverse = true;
|
||||
choosePrevious = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
reverse = false;
|
||||
chooseNext = true;
|
||||
if(current_effect>0) choosePrevious=true;
|
||||
else
|
||||
{
|
||||
reverse = false;
|
||||
chooseNext = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue