added option menu with rendering toggles

master
Sylvain PILLOT 7 months ago
parent 50fdc17071
commit 71b969b8d0
  1. 124
      CppOutRun.layout
  2. 2
      src/include/drawstuff.h
  3. 4
      src/include/menus.h
  4. 26
      src/main.cc
  5. 7
      src/src/drawstuff.cc
  6. 160
      src/src/menus.cc

@ -2,125 +2,135 @@
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Release" />
<File name="src/include/camera.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/drawstuff.cc" open="1" top="1" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="221" topLine="0" />
<Cursor1 position="2487" topLine="20" />
</Cursor>
<Folding>
<Collapse line="9" />
<Collapse line="33" />
<Collapse line="40" />
<Collapse line="46" />
<Collapse line="76" />
<Collapse line="126" />
</Folding>
</File>
<File name="src/main.cc" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/camera.cc" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="21243" topLine="603" />
<Cursor1 position="370" topLine="0" />
</Cursor>
</File>
<File name="src/include/circuit.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/camera.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1291" topLine="57" />
<Cursor1 position="221" topLine="0" />
</Cursor>
</File>
<File name="src/colors.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="TODO.txt" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="35" topLine="0" />
<Cursor1 position="251" topLine="0" />
</Cursor>
</File>
<File name="src/src/clouds.cc" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/main.cc" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="203" topLine="0" />
<Cursor1 position="16109" topLine="579" />
</Cursor>
</File>
<File name="src/include/drawstuff.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/menus.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="622" topLine="0" />
<Cursor1 position="328" topLine="0" />
</Cursor>
</File>
<File name="CMakeLists.txt" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/circuit.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2715" topLine="65" />
<Cursor1 position="1291" topLine="57" />
</Cursor>
</File>
<File name="src/src/circuit.cc" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/clouds.cc" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3969" topLine="137" />
<Cursor1 position="203" topLine="0" />
</Cursor>
<Folding>
<Collapse line="433" />
<Collapse line="501" />
<Collapse line="517" />
<Collapse line="588" />
<Collapse line="633" />
<Collapse line="1092" />
<Collapse line="1099" />
<Collapse line="1109" />
<Collapse line="1119" />
</Folding>
</File>
<File name="src/src/menus.cc" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/cars.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="14167" topLine="333" />
<Cursor1 position="332" topLine="0" />
</Cursor>
<Folding>
<Collapse line="32" />
<Collapse line="96" />
<Collapse line="330" />
</Folding>
</File>
<File name="src/src/cars.cc" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1019" topLine="8" />
</Cursor>
</File>
<File name="src/src/camera.cc" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/drawstuff.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="370" topLine="0" />
<Cursor1 position="637" topLine="0" />
</Cursor>
</File>
<File name="src/include/clouds.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/colors.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="306" topLine="0" />
<Cursor1 position="35" topLine="0" />
</Cursor>
</File>
<File name="src/fixed.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="CMakeLists.txt" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="778" topLine="0" />
<Cursor1 position="2715" topLine="65" />
</Cursor>
</File>
<File name="src/include/segment.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/clouds.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="210" topLine="0" />
<Cursor1 position="306" topLine="0" />
</Cursor>
</File>
<File name="src/src/segment.cc" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="2" zoom_2="0">
<File name="src/src/circuit.cc" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="230" topLine="30" />
<Cursor1 position="16878" topLine="925" />
</Cursor>
<Folding>
<Collapse line="433" />
<Collapse line="501" />
<Collapse line="517" />
<Collapse line="588" />
<Collapse line="633" />
<Collapse line="1092" />
<Collapse line="1099" />
<Collapse line="1109" />
<Collapse line="1119" />
</Folding>
</File>
<File name="src/include/menus.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/fixed.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="251" topLine="0" />
<Cursor1 position="778" topLine="0" />
</Cursor>
</File>
<File name="src/include/cars.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/segment.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="332" topLine="0" />
<Cursor1 position="210" topLine="0" />
</Cursor>
</File>
<File name="src/parameters.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/parameters.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="327" topLine="0" />
<Cursor1 position="559" topLine="0" />
</Cursor>
</File>
<File name="src/src/drawstuff.cc" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/menus.cc" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2516" topLine="0" />
<Cursor1 position="16293" topLine="115" />
</Cursor>
<Folding>
<Collapse line="33" />
<Collapse line="40" />
<Collapse line="76" />
<Collapse line="39" />
<Collapse line="77" />
<Collapse line="103" />
<Collapse line="164" />
<Collapse line="200" />
<Collapse line="212" />
<Collapse line="337" />
<Collapse line="349" />
<Collapse line="391" />
<Collapse line="462" />
</Folding>
</File>
<File name="TODO.txt" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/segment.cc" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="2" zoom_2="0">
<Cursor>
<Cursor1 position="251" topLine="0" />
<Cursor1 position="230" topLine="30" />
</Cursor>
</File>
</CodeBlocks_layout_file>

@ -7,7 +7,7 @@ void drawPolygon( int x1min, int x1max, int y1, int x2min, int x2max, int y2, ui
void drawGrass( int y1, int y2, uint8_t R, uint8_t G, uint8_t B );
void drawGrass( int y1, int y2, uint16_t color );
void drawSky( void );
void drawSkyFull( uint16_t color );
void drawSky( uint16_t color );
void drawSky( uint8_t R, uint8_t G, uint8_t B );
void drawSky( int ymin, int ymax );

@ -14,4 +14,8 @@ void getInputCircuitSelect( void );
void drawCredit( void );
void getInputCredit( void );
void drawOptions( void );
void getInputOptions( void );
#endif // MENUS_H

@ -64,8 +64,12 @@ bool ShowDebug3 = false;
bool BDrawDeco = true;
bool BDrawClds = true;
bool BDrawCars = true;
bool BDrawBack = true;
bool BDrawFPS = false;
bool OptionMode = false;
bool PauseMode = false;
uint16_t currentcurve=0;
uint8_t shiftcolor=0;
@ -257,6 +261,8 @@ static void get_inputs( float dt, int index )
if(keydown(KEY_EXIT)) stop = true;
if(keydown(KEY_OPTN)) drawOptions();
#if IS_FXLIB==1
if(keydown(KEY_XOT))
{
@ -392,7 +398,7 @@ int main(void)
}
else if (stage==2)
{
// Option Menu TO BE DONE
drawOptions();
}
else if (stage==3)
{
@ -555,7 +561,7 @@ int main(void)
{
projectCircuitFP( k ); // We project the current segment
if (circuit[k]->Y < minYRoad) // This is a trick to save precious time while drawing the Sky
if (k!= indexend && circuit[k]->Y < minYRoad) // This is a trick to save precious time while drawing the Sky
minYRoad = circuit[k]->Y;
circuit[k]->CumulatedCurve = cumulCurve; // This is the curve accumulated when we are drawing curves
@ -579,13 +585,21 @@ int main(void)
prof_enter(perf_render);
drawSky( DAY_BLUE_SKY );
if (BDrawBack) drawSkyOptimised( DAY_BLUE_SKY );
else drawSkyFull( DAY_BLUE_SKY );
if (BDrawClds)
{
drawClouds( );
}
if (BDrawBack)
{
drawFarBackground( deltaFarbackground, CurrentCircuitBiome );
drawNearBackground( deltaNearbackground, CurrentCircuitBiome );
}
drawFarBackground( deltaFarbackground, CurrentCircuitBiome );
drawNearBackground( deltaNearbackground, CurrentCircuitBiome );
cam->cY = fix( 300+2*CS ) + interpolatePositionY(fround(cam->cZ) );
@ -605,7 +619,7 @@ int main(void)
drawTraffic( indexCar );
}
circuit[k]->CarList.clear();
if (BDrawCars) circuit[k]->CarList.clear();
}
if (circuit[indexstart]->Special == CHECKPOINT && circuit[indexstart]->CheckValidated == false)

@ -100,9 +100,10 @@ void drawPolygon( int x1min, int x1max, int y1, int x2min, int x2max, int y2, ui
};
void drawSky( void )
void drawSkyFull( uint16_t color )
{
dclear( C_RGB(0,45,255) );
//dclear( color );
dma_memset(gint_vram, (color << 16) | color, 396 * 174 * 2);
};
@ -113,7 +114,7 @@ void drawSky( uint16_t color )
void drawSkyOptimised( uint16_t color )
{
dma_memset(gint_vram, (color << 16) | color, 396 * (minYRoad+1) * 2);
dma_memset(gint_vram, (color << 16) | color, 396 * (minYRoad+10) * 2);
};
void drawSky( uint8_t R, uint8_t G, uint8_t B )

@ -26,7 +26,14 @@ int8_t CircuitSelection=0;
bool doneMenuCredit = false;
bool doneOptions = false;
uint8_t OptionsSelection=0;
extern bool BDrawDeco;
extern bool BDrawClds;
extern bool BDrawCars;
extern bool BDrawFPS;
extern bool BDrawBack;
void drawStartTitle( void )
@ -475,5 +482,158 @@ void getInputCredit( void )
}
void drawOptions( void )
{
uint16_t pulse=0;
doneOptions = false;
OptionsSelection=0;
while (!doneOptions)
{
dclear(0x0000);
dimage( 0, 0, &mainscreen);
dfont(&autofont);
if (BDrawDeco)
{
dprint_opt(102, 22, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "SCENERY [Y]" );
if (OptionsSelection!=0) dprint_opt(100, 20, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "SCENERY [Y]" );
else dprint_opt(100, 20, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "SCENERY [Y]" );
}
else
{
dprint_opt(102, 22, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "SCENERY [N]" );
if (OptionsSelection!=0) dprint_opt(100, 20, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "SCENERY [N]" );
else dprint_opt(100, 20, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "SCENERY [N]" );
}
if (BDrawCars)
{
dprint_opt(102, 52, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "OPPONENTS [Y]" );
if (OptionsSelection!=1) dprint_opt(100, 50, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "OPPONENTS [Y]" );
else dprint_opt(100, 50, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "OPPONENTS [Y]" );
}
else
{
dprint_opt(102, 52, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "OPPONENTS [N]" );
if (OptionsSelection!=1) dprint_opt(100, 50, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "OPPONENTS [N]" );
else dprint_opt(100, 50, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "OPPONENTS [N]" );
}
if (BDrawClds)
{
dprint_opt(102, 82, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CLOUDS [Y]" );
if (OptionsSelection!=2) dprint_opt(100, 80, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CLOUDS [Y]" );
else dprint_opt(100, 80, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CLOUDS [Y]" );
}
else
{
dprint_opt(102, 82, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CLOUDS [N]" );
if (OptionsSelection!=2) dprint_opt(100, 80, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CLOUDS [N]" );
else dprint_opt(100, 80, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CLOUDS [N]" );
}
if (BDrawBack)
{
dprint_opt(102, 112, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACKGROUND [Y]" );
if (OptionsSelection!=3) dprint_opt(100, 110, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACKGROUND [Y]" );
else dprint_opt(100, 110, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACKGROUND [Y]" );
}
else
{
dprint_opt(102, 112, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACKGROUND [N]" );
if (OptionsSelection!=3) dprint_opt(100, 110, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACKGROUND [N]" );
else dprint_opt(100, 110, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACKGROUND [N]" );
}
if (BDrawFPS)
{
dprint_opt(102, 142, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "STATS-FPS [Y]" );
if (OptionsSelection!=4) dprint_opt(100, 140, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "STATS-FPS [Y]" );
else dprint_opt(100, 140, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "STATS-FPS [Y]" );
}
else
{
dprint_opt(102, 142, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "STATS-FPS [N]" );
if (OptionsSelection!=4) dprint_opt(100, 140, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "STATS-FPS [N]" );
else dprint_opt(100, 140, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "STATS-FPS [N]" );
}
dprint_opt(102, 172, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACK TO GAME" );
if (OptionsSelection!=5) dprint_opt(100, 170, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACK TO GAME" );
else dprint_opt(100, 170, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACK TO GAME" );
dimage( 10, 5+30*OptionsSelection, &flag );
// CODE HERE TO PRINT WELCOME MENU
dupdate();
pulse++;
getInputOptions();
#if IS_FXLIB==1
if (screenshot && usb_is_open())
{
usb_fxlink_screenshot(false);
screenshot = false;
}
if(record && usb_is_open())
{
usb_fxlink_videocapture(false);
}
#endif
}
return;
}
void getInputOptions( void )
{
int opt = GETKEY_DEFAULT & ~GETKEY_REP_ARROWS;
int timeout = 1;
while(1)
{
key_event_t ev = getkey_opt(opt, &timeout);
if(ev.type == KEYEV_NONE) return;
int key = ev.key;
if (key==KEY_EXE)
{
if (OptionsSelection==0) BDrawDeco = !BDrawDeco;
else if (OptionsSelection==1) BDrawCars = !BDrawCars;
else if (OptionsSelection==2) BDrawClds = !BDrawClds;
else if (OptionsSelection==3) BDrawBack = !BDrawBack;
else if (OptionsSelection==4) BDrawFPS = !BDrawFPS;
else doneOptions=true;
}
if (key==KEY_UP)
{
if (OptionsSelection==0) OptionsSelection=5;
else OptionsSelection--;
}
if (key==KEY_DOWN)
{
if (OptionsSelection==5) OptionsSelection=0;
else OptionsSelection++;
}
#if IS_FXLIB==1
if(keydown(KEY_F5)) screenshot = true;
if(keydown(KEY_F6)) record = !record;
#endif // IS_FXLIB
}
}

Loading…
Cancel
Save