Changes

Jump to navigation Jump to search
Line 27: Line 27:     
==Source Code==
 
==Source Code==
'''Code as of 7-11-09.
+
'''Code as of 7-16-09. ''' 
   −
Recoded. The only problem is the code dump I get when trying to use exit_menu(), but nothing major.''' I know there's some weird stuff going on, but I just wanted to update for current progress. Also some tests/debugging are included, but won't be in demo/release.
+
Yes, there's a lot of weird stuff going on, but I'm working on that. Also in '''settings.hpp''' part of the code is excerpted from teknecal's Tutorial 13 on saving and loading from XML files. I'll recode/fix it later. [[User:TPAINROXX|<font face="VINETA BT"><font color="black">-TPAINROXX</font>/<font color="green">BKW</font></font>]] 00:25, 17 July 2009 (UTC)
   −
 
+
<div style="float: left;">
''' ''main.cpp'' '''
+
{| class="wikitable collapsible collapsed"
<source lang=cpp>
+
|-
 +
! main.cpp
 +
|-
 +
| ''' ''main.cpp'' '''
 +
|<source lang=cpp>
 
/***********************************************/
 
/***********************************************/
 
/*      WiiMoveIt - By Brandon Whitmire      */
 
/*      WiiMoveIt - By Brandon Whitmire      */
 
/*          Powered Using GRRLIB 4.0.0        */
 
/*          Powered Using GRRLIB 4.0.0        */
 +
/*                  main.cpp                  */
 
/***********************************************/
 
/***********************************************/
 +
 +
/************************************************
 +
TODO:
 +
 +
-Add Music/Sound Effects
 +
-Add Multiplayer
 +
-Add More Games
 +
-Add Better Games
 +
-Add Bosses
 +
-Add Storyline
 +
-Add Videos
 +
 +
~Fix screenshot destination
 +
~Use latest GRRLIB SVN
 +
 +
************************************************/
 +
#ifndef main_WiiMoveIt_cpp  //Not necessarily necessary, but...
 +
#define main_WiiMoveIt_cpp
    
#include "games.hpp"
 
#include "games.hpp"
   −
#ifndef __VER__
+
#define __VER__ "1.0 DEMO" //For version display
#define __VER__ "1.0 DEMO"
  −
#endif
     −
int main()
+
void game_version()
 
{
 
{
WiiLightOn();
  −
  −
GRRLIB_Init();
  −
  −
WPAD_Init();
  −
   
GRRLIB_texImg tex_font1 = GRRLIB_LoadTexture(font1);
 
GRRLIB_texImg tex_font1 = GRRLIB_LoadTexture(font1);
 
     GRRLIB_InitTileSet(&tex_font1, 32, 32, 32);
 
     GRRLIB_InitTileSet(&tex_font1, 32, 32, 32);
  −
GRRLIB_Printf(300, 30, tex_font1, LIME, 2, "LOADING...");
  −
  −
GRRLIB_Render();
  −
  −
WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
  −
  −
WPAD_SetVRes(0, 640, 480);
   
 
 
time(&start_time);
 
time(&start_time);
Line 70: Line 77:  
clrscr();
 
clrscr();
 
 
GRRLIB_Printf(15, 30, tex_font1, AQUA, 1, "VERSION v%s", __VER__);
+
GRRLIB_Printf(60, 60, tex_font1, WHITE, 2, "LOADING...");
 +
 +
GRRLIB_Printf(15, 150, tex_font1, LIME, 1, "VERSION v%s", __VER__);
 
 
GRRLIB_Printf(15, 180, tex_font1, AQUA, 1, "DATE: %s", __DATE__);
+
GRRLIB_Printf(15, 230, tex_font1, LIME, 1, "DATE: %s", __DATE__);
 
 
GRRLIB_Printf(15, 330, tex_font1, AQUA, 1, "TIME: %s", __TIME__);
+
GRRLIB_Printf(15, 310, tex_font1, LIME, 1, "TIME: %s", __TIME__);
 
 
GRRLIB_Printf(380, 10, tex_font1, LIME, 2, "WIIMOVEIT");
+
GRRLIB_Printf(15, 400, tex_font1, GREEN, 2, "WIIMOVEIT");
 
 
 
GRRLIB_Render();
 
GRRLIB_Render();
Line 82: Line 91:  
time(&cur_time);
 
time(&cur_time);
 
 
if ( (cur_time - start_time) > 5 )
+
if ( (cur_time - start_time) > 5)
{break;}
  −
  −
WPAD_ScanPads();
  −
  −
if  (WPAD_ButtonsHeld(0) && WPAD_BUTTON_PLUS)  
   
{break;}
 
{break;}
 
}
 
}
    
free(tex_font1.data);
 
free(tex_font1.data);
+
}
intro();
+
 
+
int main()
exit_menu();
+
{
+
GRRLIB_texImg tex_font1 = GRRLIB_LoadTexture(font1);
 
     GRRLIB_InitTileSet(&tex_font1, 32, 32, 32);
 
     GRRLIB_InitTileSet(&tex_font1, 32, 32, 32);
 
 
time(&start_time);
+
update_settings();
 
 
while(1)
+
while(1)
 
{
 
{
GRRLIB_FillScreen(BLACK);
+
clrscr();
  −
GRRLIB_Printf(15, 30, tex_font1, AQUA, 1, "YOU CANCELLED!");
   
 
 +
load_settings() ? GRRLIB_Printf(60, 60, tex_font1, WHITE, 1, "SETTINGS LOADED!") : GRRLIB_Printf(60, 60, tex_font1, WHITE, 1, "ERROR LOADING SETTINGS!");
 +
 
GRRLIB_Render();
 
GRRLIB_Render();
  −
time(&cur_time);
  −
  −
if ( (cur_time - start_time) > 5 )
  −
{break;}
   
 
 
WPAD_ScanPads();
 
WPAD_ScanPads();
+
if (WPAD_ButtonsHeld(0) && WPAD_BUTTON_PLUS)  
+
if (WPAD_ButtonsHeld(0) && WPAD_BUTTON_HOME)
 
{break;}
 
{break;}
 
}
 
}
 +
 +
free(tex_font1.data);
 +
 +
WLToggle();
 +
 +
GRRLIB_Init();
 +
 +
WPAD_Init();
 +
 +
WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
 +
 +
WPAD_SetVRes(0, 640, 480);
 +
 +
game_version(); //This displays the version and other version data.
 
 
free(tex_font1.data);
+
intro();
 +
 +
exit_menu();
 
 
 
GRRLIB_Exit();
 
GRRLIB_Exit();
 
 
WiiLightOff();
+
WLToggle();
 
 
 
return 0;
 
return 0;
 
}
 
}
 +
 +
//---------------------------------------------------------
 +
//    End of main.cpp
 +
//---------------------------------------------------------
 +
 +
#endif //main_WiiMoveIt_cpp
 +
 
</source>
 
</source>
 +
|}
 +
</div>
   −
''' ''games.hpp'' '''
+
 
<source lang=cpp>
+
<div style="float: left;">
 +
{| class="wikitable collapsible collapsed"
 +
|-
 +
! games.cpp
 +
|-
 +
| ''' '' games.hpp '' '''
 +
|<source lang=cpp>
 
//---------------------------------------------------------
 
//---------------------------------------------------------
//    games.cpp - Includes basic game engine/thing.
+
//    games.cpp - Includes basic game engine.
 
//---------------------------------------------------------
 
//---------------------------------------------------------
 
/*********************************************************/
 
/*********************************************************/
 +
 +
#ifndef games_WiiMoveIt_hpp  //To prevent multiple inclusions.
 +
#define games_WiiMoveIt_hpp
 +
 
//---------------------------------------------------------
 
//---------------------------------------------------------
 
//    GRRLIB - So Important it has its own spot....
 
//    GRRLIB - So Important it has its own spot....
Line 141: Line 175:     
#include "GRRLIB/GRRLIB/GRRLIB.h" //Version packed with GRRLIB 4.0.0
 
#include "GRRLIB/GRRLIB/GRRLIB.h" //Version packed with GRRLIB 4.0.0
 +
 +
//---------------------------------------------------------
 +
//    Settings File
 +
//---------------------------------------------------------
 +
 +
#include "settings.hpp"
    
//---------------------------------------------------------
 
//---------------------------------------------------------
Line 146: Line 186:  
//---------------------------------------------------------
 
//---------------------------------------------------------
   −
#include <cstdlib>
   
#include <time.h> //For time comparison.
 
#include <time.h> //For time comparison.
 
#include <unistd.h>  //For usleep();
 
#include <unistd.h>  //For usleep();
Line 164: Line 203:  
//    Credits/Intro
 
//    Credits/Intro
 
//---------------------------------------------------------
 
//---------------------------------------------------------
 +
 +
#include "credits/intro/swirl.h"
 +
#include "credits/intro/TPAINROXX.h"
    
#include "credits/BKGD.h"
 
#include "credits/BKGD.h"
Line 192: Line 234:  
#include "Menu/Highlight.h"
 
#include "Menu/Highlight.h"
 
#include "Menu/Highlight2.h"
 
#include "Menu/Highlight2.h"
  −
//---------------------------------------------------------
  −
//    Options
  −
//---------------------------------------------------------
  −
  −
/***
  −
  *
  −
  *
  −
  *
  −
  *TO BE CODED LATER
  −
  *
  −
  *
  −
  *
  −
***/
      
//---------------------------------------------------------
 
//---------------------------------------------------------
Line 265: Line 293:  
Mtx GXmodelView2D;  //Needed for GRRLIB
 
Mtx GXmodelView2D;  //Needed for GRRLIB
   −
void clrscr()      //"Clears Screen"...
+
void clrscr()      //"Clears Screen"... for quick screen clearing...
 
{GRRLIB_FillScreen(BLACK);}
 
{GRRLIB_FillScreen(BLACK);}
   −
//Wiimote 1
+
time_t start_time, cur_time;  //Time delays/comparisons.
 +
 
 +
/*Wiimote 1 DATA*/
 +
 
 
ir_t ir1;  //IR Movement
 
ir_t ir1;  //IR Movement
 
 
 
orient_t or1;  //Orientation Movement
 
orient_t or1;  //Orientation Movement
   −
time_t start_time, cur_time;  //Time delays/comparisons.
+
/*Wii Light - Thanks to Crayon... again...*/
   −
//Wii Light - Thanks to Crayon... again...
+
static vu32 *_wiilight_reg = (u32*)0xCD0000C0;
 +
/*
 +
void WiiLightOff()
 +
{*_wiilight_reg &= 0x20;}
   −
static vu32 *_wiilight_reg = (u32*)0xCD0000C0;
+
void WiiLightOn()
 +
{*_wiilight_reg |= 0x20;}
 +
*/
 +
bool do_wiilight = true; //For toggling on and off.
   −
void WiiLightOff()
+
void WLToggle() //Toggles WiiLight on and off
 
{
 
{
    *_wiilight_reg &= ~0x20;
+
if (wiilight)  //From settings; if true then it does \/.
 +
{do_wiilight ? *_wiilight_reg |= 0x20 : *_wiilight_reg &= 0x20;}
 
}
 
}
   −
void WiiLightOn()
+
//---------------------------------------------------------
 +
//    Rumble Stuff
 +
//---------------------------------------------------------
 +
 
 +
#define P1 0  //For easy understanding.
 +
#define P2 1
 +
 
 +
bool do_rumble = true;
 +
 
 +
void rumble(u32 _wiimote_channel_or_PLAYER_NUMBER_)
 
{
 
{
    *_wiilight_reg |= 0x20;
+
if (rumbling)
 +
{
 +
if (do_rumble)
 +
{
 +
WPAD_Rumble( _wiimote_channel_or_PLAYER_NUMBER_, 1);
 +
 +
usleep(25000);
 +
 +
WPAD_Rumble( _wiimote_channel_or_PLAYER_NUMBER_, 0);
 +
 +
do_rumble = false;
 +
}
 +
}
 
}
 
}
   Line 294: Line 353:     
bool IRposition (int IRx1, int IRy1, int IRx2, int IRy2, ir_t IR_T)
 
bool IRposition (int IRx1, int IRy1, int IRx2, int IRy2, ir_t IR_T)
/*                 Min X     Min Y    Max X    Max Y    IR Struct (i.e. ir1)
+
/*               Min X     Min Y    Max X    Max Y    IR Struct (i.e. ir1)
Return true if a point lies within specified coodinates based off the IR.*/
+
Returns true if a point lies within specified coodinates based off the IR.*/
 
{return ((IRx1 <= IR_T.x) && (IRx2 >= IR_T.x) && (IRy1 <= IR_T.y) && (IRy2 >= IR_T.y));}
 
{return ((IRx1 <= IR_T.x) && (IRx2 >= IR_T.x) && (IRy1 <= IR_T.y) && (IRy2 >= IR_T.y));}
   Line 314: Line 373:  
 
 
GRRLIB_DrawImg(0, 0, tex_Exit, 0, 1, 1, SILVER);
 
GRRLIB_DrawImg(0, 0, tex_Exit, 0, 1, 1, SILVER);
  −
WPAD_IR(WPAD_CHAN_0, &ir1);
  −
WPAD_Orientation(WPAD_CHAN_0, &or1); 
  −
  −
GRRLIB_DrawImg(ir1.x, ir1.y, tex_Pointer, or1.roll, ir1.z, ir1.z, SILVER);
   
 
 
WPAD_ScanPads();
 
WPAD_ScanPads();
 
 
if (WPAD_ButtonsHeld(0) && WPAD_BUTTON_HOME)// Cancel
+
if ( IRposition (476, 61, 625, 210, ir1) ) //Cancel
{break;}
+
{
 +
rumble(P1);
 
 
else if ( IRposition (476, 61, 625, 210, ir1) )  //Cancel
  −
{
   
GRRLIB_DrawImg(476, 61, tex_Highlight, 0, 1, 1, SILVER);
 
GRRLIB_DrawImg(476, 61, tex_Highlight, 0, 1, 1, SILVER);
 
 
Line 335: Line 388:  
else if ( IRposition (16, 61, 165, 210, ir1) ) //To Wii Menu.
 
else if ( IRposition (16, 61, 165, 210, ir1) ) //To Wii Menu.
 
{
 
{
 +
rumble(P1);
 +
 
GRRLIB_DrawImg(16, 61, tex_Highlight, 0, 1, 1, SILVER);
 
GRRLIB_DrawImg(16, 61, tex_Highlight, 0, 1, 1, SILVER);
 
 
Line 343: Line 398:  
else if ( IRposition (221, 61, 420, 260, ir1) )  //To Loader.
 
else if ( IRposition (221, 61, 420, 260, ir1) )  //To Loader.
 
{
 
{
 +
rumble(P1);
 +
 
GRRLIB_DrawImg(221, 61, tex_Highlight2, 0, 1, 1, SILVER);  //Box is slightly bigger.
 
GRRLIB_DrawImg(221, 61, tex_Highlight2, 0, 1, 1, SILVER);  //Box is slightly bigger.
 
 
Line 351: Line 408:  
else if ( IRposition (96, 271, 245, 420, ir1) )  //Turn off Wii.
 
else if ( IRposition (96, 271, 245, 420, ir1) )  //Turn off Wii.
 
{
 
{
 +
rumble(P1);
 +
 
GRRLIB_DrawImg(96, 271, tex_Highlight, 0, 1, 1, SILVER);
 
GRRLIB_DrawImg(96, 271, tex_Highlight, 0, 1, 1, SILVER);
 
 
Line 359: Line 418:  
else if ( IRposition (386, 271, 535, 420, ir1) )  //Reset Wii.
 
else if ( IRposition (386, 271, 535, 420, ir1) )  //Reset Wii.
 
{
 
{
 +
rumble(P1);
 +
 
GRRLIB_DrawImg(386, 271, tex_Highlight, 0, 1, 1, SILVER);
 
GRRLIB_DrawImg(386, 271, tex_Highlight, 0, 1, 1, SILVER);
 
 
Line 364: Line 425:  
{SYS_ResetSystem(SYS_RESTART, 0, 0);}  
 
{SYS_ResetSystem(SYS_RESTART, 0, 0);}  
 
}
 
}
 +
 +
else
 +
{do_rumble = true;}
 +
 +
WPAD_IR(WPAD_CHAN_0, &ir1);
 +
WPAD_Orientation(WPAD_CHAN_0, &or1); 
 +
 +
GRRLIB_DrawImg( (ir1.x - tex_Pointer.w), (ir1.y - tex_Pointer.h), tex_Pointer, or1.roll, ir1.z, ir1.z, SILVER);
 
 
 
GRRLIB_Render();
 
GRRLIB_Render();
Line 371: Line 440:  
free(tex_Pointer.data);
 
free(tex_Pointer.data);
 
free(tex_Highlight.data);
 
free(tex_Highlight.data);
 +
free(tex_Highlight2.data);
 
}
 
}
   Line 377: Line 447:  
//---------------------------------------------------------
 
//---------------------------------------------------------
   −
void END() //Test.
+
struct _intro_data
 +
{
 +
int x, y; //Positions
 +
 +
int deg;  //Degrees
 +
 +
float sx, sy; //Scaling
 +
} dINTRO, dGRRLIB, dGIMP, dBKW2, dDEVKIT, dTPR_BKW; //d prefix added because of errors relating to texture loading.
 +
 
 +
#define MAX_PIXELATE 1
 +
 
 +
bool no_do_it = true;
 +
 
 +
void TPAINROXX_BKW()
 
{
 
{
GRRLIB_texImg tex_font2 = GRRLIB_LoadTexture(font2);
+
GRRLIB_texImg tex_swirl = GRRLIB_LoadTexture(swirl);
GRRLIB_InitTileSet(&tex_font2, 16, 16, 32);
+
 +
GRRLIB_texImg tex_swirl2; // For effects.
 +
float pixelate = 0;
 
 
time(&start_time);
+
GRRLIB_texImg tex_TPR_BKW = GRRLIB_LoadTexture(TPAINROXX);
 +
 +
dTPR_BKW.deg = 0;
 
 
 
while(1)
 
while(1)
 
{
 
{
 
clrscr();
 
clrscr();
  −
GRRLIB_Printf(25, 430, tex_font2, BLUE, 1.75, "END? - TO BE CONTINUED...");
  −
  −
GRRLIB_Render();
   
 
time(&cur_time);
+
GRRLIB_BMFX_Pixelate(tex_swirl, tex_swirl2, pixelate);
 +
 +
GRRLIB_DrawImg( (320 - tex_swirl2.w), (240 - tex_swirl2.h), tex_swirl2, dTPR_BKW.deg, 1, 1, BLACK);
 +
 +
if ( !(pixelate >= MAX_PIXELATE) )
 +
{
 +
pixelate += .02;
 +
dTPR_BKW.deg++;
 +
}
 +
 +
else
 +
{
 +
pixelate = 0;
 +
dTPR_BKW.deg = 0;
 +
 +
GRRLIB_DrawImg( (320 - tex_TPR_BKW.w), ( (240 - tex_TPR_BKW.h) - tex_swirl2.h), tex_TPR_BKW, 0, 1, 1, BLACK);
 +
 +
if (no_do_it)
 +
{
 +
time(&start_time);
 +
no_do_it = false;
 +
}
 +
 +
time(&cur_time);
 +
 +
if ( (cur_time - start_time) > 5)
 +
{break;}
 +
}
 
 
if ((cur_time - start_time) >= 3)
+
GRRLIB_Render();
{break;}
  −
   
}
 
}
 
 
free(tex_font2.data);
+
free(tex_TPR_BKW.data);
 +
free(tex_swirl.data);
 
}
 
}
    
void intro()
 
void intro()
 
{
 
{
 +
// TPAINROXX_BKW();
 +
 
GRRLIB_texImg tex_BKGD = GRRLIB_LoadTexture(BKGD);
 
GRRLIB_texImg tex_BKGD = GRRLIB_LoadTexture(BKGD);
 
GRRLIB_texImg tex_GRRLIB = GRRLIB_LoadTexture(GRRLIB);
 
GRRLIB_texImg tex_GRRLIB = GRRLIB_LoadTexture(GRRLIB);
Line 409: Line 520:  
GRRLIB_texImg tex_BKW2 = GRRLIB_LoadTexture(BKW2);
 
GRRLIB_texImg tex_BKW2 = GRRLIB_LoadTexture(BKW2);
 
GRRLIB_texImg tex_Devkitlogo = GRRLIB_LoadTexture(Devkitlogo);
 
GRRLIB_texImg tex_Devkitlogo = GRRLIB_LoadTexture(Devkitlogo);
  −
struct _intro_data
  −
{
  −
int x, y; //Positions
  −
  −
int deg;  //Degrees
  −
  −
float sx, sy;  //Scaling
  −
} dINTRO, dGRRLIB, dGIMP, dBKW2, dDEVKIT; //d prefix added because of errors relating to texture loading.
   
 
 
dINTRO.sx = 0, dINTRO.sy = 0;
 
dINTRO.sx = 0, dINTRO.sy = 0;
Line 430: Line 532:  
 
 
if (dINTRO.sx >= 1) //Just to make sure...
 
if (dINTRO.sx >= 1) //Just to make sure...
{break;}
  −
  −
WPAD_ScanPads();
  −
  −
if (WPAD_ButtonsHeld(0) && WPAD_BUTTON_PLUS)  //For debugging; in case it never breaks.
   
{break;}
 
{break;}
 
 
Line 524: Line 621:  
WPAD_ScanPads();
 
WPAD_ScanPads();
 
 
if (WPAD_ButtonsHeld(0) && WPAD_BUTTON_PLUS)
+
if (WPAD_ButtonsHeld(0) && WPAD_BUTTON_HOME)
 
{break;}
 
{break;}
 
}
 
}
Line 533: Line 630:  
free(tex_BKW2.data);
 
free(tex_BKW2.data);
 
free(tex_Devkitlogo.data);
 
free(tex_Devkitlogo.data);
 +
}
 +
 +
//---------------------------------------------------------
 +
//    End of games.cpp
 +
//---------------------------------------------------------
 +
 +
#endif //games_WiiMoveIt_hpp
 +
</source>
 +
|}
 +
</div>
 +
 +
 +
<div style="float: left;">
 +
{| class="wikitable collapsible collapsed"
 +
|-
 +
! settings.cpp
 +
|-
 +
| ''' '' settings.hpp '' '''
 +
|<source lang = cpp>
 +
//---------------------------------------------------------
 +
//    settings.hpp - Includes settings/options.
 +
//---------------------------------------------------------
 +
/*********************************************************/
 +
 +
#ifndef settings_WiiMoveIt_hpp  //To prevent multiple inclusions.
 +
#define settings_WiiMoveIt_hpp
 +
 +
//---------------------------------------------------------
 +
//    XML Library from Beardface, so thanks.
 +
//    -lmxml needs to be added to makefile
 +
//---------------------------------------------------------
 +
 +
#include "XML/mxml.h"
 +
 +
#include <cstdlib>
 +
 +
#include <zlib.h>
 +
 +
//=========================================================
 +
//    Settings Functions
 +
//=========================================================
 +
 +
/**********************************************************
 +
TODO:
 +
 +
-Convert to C++ or something (most of this code
 +
has been excerpted from Tutorial 13 of teknecal's
 +
codemii tutorials)
 +
 +
**********************************************************/
 +
 +
//---------------------------------------------------------
 +
//    Settings Variables
 +
//---------------------------------------------------------
 +
 +
const char set_dest[] = "sd:/apps/WiiMoveIt_V1.0/data/settings/WiiMoveIt.xml";
 +
 +
bool rumbling  = true;
 +
 +
#define EASY  0
 +
#define NORMAL 1
 +
#define HARD  2
 +
 +
unsigned int difficulty = EASY;
 +
 +
bool menu = true;
 +
 +
bool wiilight = true;
 +
 +
bool update_settings()
 +
{
 +
mxml_node_t *xml;
 +
mxml_node_t *data;
 +
xml = mxmlNewXML("1.0");
 +
 +
data = mxmlNewElement(xml, "settings");
 +
 +
char set1[1];
 +
sprintf(set1, "%i", rumbling);
 +
mxmlElementSetAttr(data, "rumble", set1);
 +
char set2[1];
 +
sprintf(set2, "%i", difficulty);
 +
mxmlElementSetAttr(data, "difficulty", set2);
 +
char set3[1];
 +
sprintf(set3, "%i", menu);
 +
mxmlElementSetAttr(data, "menu", set3);
 +
char set4[1];
 +
sprintf(set4, "%i", wiilight);
 +
mxmlElementSetAttr(data, "wiilight", set4);
 +
 +
FILE *f;
 +
f = fopen( set_dest, "wb");
 +
 +
if (f == NULL) //Settings failed
 +
{
 +
fclose(f);
 +
 +
return false;
 +
}
 +
 +
else //Settings saved
 +
{
 +
mxmlSaveFile(xml, f, MXML_NO_CALLBACK);
 +
fclose(f);
 +
mxmlDelete(data);
 +
mxmlDelete(xml);
 +
 +
return true;
 +
}
 +
}
 +
 +
bool load_settings()
 +
{
 +
mxml_node_t *tree;
 +
mxml_node_t *data;
 +
 +
FILE *fp = fopen(set_dest, "rb");
 +
 +
if (fp == NULL)
 +
{
 +
fclose(fp);
 +
return false;
 +
}
 +
 +
else
 +
{
 +
fseek (fp , 0, SEEK_END);
 +
long settings_size = ftell (fp);
 +
rewind (fp);
 +
 +
if (settings_size > 0)
 +
{
 +
 +
tree = mxmlLoadFile(NULL, fp, MXML_NO_CALLBACK);
 +
fclose(fp);
 +
 +
data = mxmlFindElement(tree, tree, "settings", NULL, NULL, MXML_DESCEND);
 +
 +
if (mxmlElementGetAttr(data,"rumble"))
 +
{
 +
rumbling = atoi(mxmlElementGetAttr(data,"rumble"));
 +
}
 +
 +
if (mxmlElementGetAttr(data,"difficulty"))
 +
{
 +
difficulty = atoi(mxmlElementGetAttr(data,"difficulty"));
 +
 +
if (difficulty > HARD)
 +
{difficulty = HARD;}
 +
}
 +
 +
if (mxmlElementGetAttr(data,"menu"))
 +
{
 +
menu = atoi(mxmlElementGetAttr(data,"menu"));
 +
}
 +
 +
if (mxmlElementGetAttr(data,"wiilight"))
 +
{
 +
wiilight = atoi(mxmlElementGetAttr(data,"wiilight"));
 +
}
 +
 +
mxmlDelete(data);
 +
mxmlDelete(tree);
 +
 +
return true;
 +
 +
}
 +
 +
else
 +
{
 +
fclose(fp);
 +
unlink(set_dest);
 +
 +
return false;
 +
}
 +
}
 +
}
 +
 +
//=========================================================
 +
//    End of Settings Functions
 +
//=========================================================
 +
 +
//---------------------------------------------------------
 +
//    Options
 +
//---------------------------------------------------------
 +
 +
void options()
 +
{
 +
/***
 +
  *
 +
  *
 +
  *
 +
  *TO BE ADDED LATER
 +
  *
 +
  *
 +
  *
 +
***/
 +
}
 +
 +
//---------------------------------------------------------
 +
//    Screenshot Function
 +
//---------------------------------------------------------
 +
 +
#define CONST_FILENAME 41
 +
 +
void SCRSHOT()
 +
{
 +
int scrshotfile = 1;
 +
 +
srand((unsigned)time(NULL)); 
 +
 +
const char def_filename[] = "sd:/apps/WiiMoveIt_v1.0/data/screenshots/";
 +
 +
char filename[scrshotfile];
 +
 +
while(1)
 +
{
 +
if ( (scrshotfile <= CONST_FILENAME))
 +
{
 +
filename[scrshotfile - 1] = def_filename[scrshotfile-1];
 +
}
 +
 +
else
 +
{
 +
filename[scrshotfile - 1] = ((char) rand());
 +
}
 +
 +
if (scrshotfile > 50) break;
 +
 +
scrshotfile++;
 +
}
 
 
END(); //A test. Should be removed if it's here.
+
GRRLIB_ScrShot(filename);
 
}
 
}
 +
 +
//---------------------------------------------------------
 +
//    End of settings.hpp
 +
//---------------------------------------------------------
 +
 +
#endif //settings_WiiMoveIt_hpp
 +
 
</source>
 
</source>
 +
|}
 +
</div>
 +
 +
<!-- Template for new code files, etc.
   −
<!-- I like saving stuff.
+
<div style="float: left;">
 +
{| class="wikitable collapsible collapsed"
 +
|-
 +
! FILENAME
 +
|-
 +
| ''' '' FILENAME '' '''
 +
|<source lang = cpp>
 +
CODE GOES HERE
 +
</source>
 +
|}
 +
</div>
   −
:Hi, did you see that post: http://grrlib.santo.fr/forum/viewtopic.php?pid=795#p795 from 2009-06-30 17:14:17? -[[User:Crayon|Crayon]] 03:05, 7 July 2009 (UTC)
  −
  −
::Oh no, I didn't see that. I'll start implementing it tomorrow (as I've been on vacation a few days...), but thanks Crayon once again! --[[User:TPAINROXX|<font face="VINETA BT"><font color="black">-TPAINROXX</font>/<font color="green">BKW</font></font>]] 03:19, 7 July 2009 (UTC)
   
-->
 
-->
  −
New source code. [[User:TPAINROXX|<font face="VINETA BT"><font color="black">-TPAINROXX</font>/<font color="green">BKW</font></font>]] 22:29, 11 July 2009 (UTC)
 
257

edits

Navigation menu