#include "CRM32Pro.h"
#define EXAMPLE_VERSION "Example 3: GUI"
#define GFX_RESOURCE "data/gfx.dpf" // DPF with graphic resources
void ModifyProgress(void *,void *);
void PrintHelp();
SDL_Surface *sBg = NULL;
char sFont[20];
int main(int argc,char *argv[])
{
SDL_Event event;
Uint32 cCursor;
const int iAdd = 1, iSub = -1;
Uint8 done = 0;
Uint32 bExitID, bID, bCheckID, bSliderID, bInputID;
Uint32 bProgressID, bAddID, bSubtractID;
PrintHelp();
if(CRM32Pro.
Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) < 0)
{
ILogSystem.
Msg(
LOG_NORMAL,
" · [LOG] - Couldnīt initialize CRM32Pro: %s\n",SDL_GetError());
return 1;
}
CRM32Pro.
Config.
Title = EXAMPLE_VERSION;
CRM32Pro.Config.
Icon = IImage->
Load(GFX_RESOURCE,
"icono");
{
return 1;
}
cCursor = ICursor->
Load(GFX_RESOURCE,
"cursor");
sBg = IImage->
Load(GFX_RESOURCE,
"background");
bExitID = IButton->
Load(GFX_RESOURCE,
"MyComplex");
bCheckID = IButton->
Load(GFX_RESOURCE,
"MyCheck");
bSliderID = IButton->
Load(GFX_RESOURCE,
"MySlider");
bInputID = IButton->
Load(GFX_RESOURCE,
"MyInput");
bProgressID = IButton->
Load(GFX_RESOURCE,
"MyProgress");
bAddID = IButton->
Load(GFX_RESOURCE,
"MyAdd");
bSubtractID = IButton->
Load(GFX_RESOURCE,
"MySubtract");
IButton->
SetFunction(bAddID,ModifyProgress,(
void*)&bProgressID,(
void*)&iAdd);
IButton->
SetFunction(bSubtractID,ModifyProgress,(
void*)&bProgressID,(
void*)&iSub);
fFont->
Load(GFX_RESOURCE,
"MyFont");
fInput->
Load(GFX_RESOURCE,
"InputFont");
IButton->
SetText(bInputID,
"CRM32Pro Example");
strcpy(sFont,"");
while(!done)
{
if(bID == bExitID) done = 1;
else if(bID == bSliderID)
{
{
strcpy(sFont,"0123456789");
}
else if(IButton->
GetValue(bSliderID) == 1)
{
strcpy(sFont,"green font");
}
else
strcpy(sFont,"ANOTHER FONT");
}
while(CRM32Pro.
Update(&event))
{
switch(event.type)
{
case SDL_QUIT:
done = 1;
break;
case SDL_KEYDOWN:
if(event.key.keysym.sym == SDLK_ESCAPE) done = 1;
if(event.key.keysym.sym == SDLK_1)
{
}
if(event.key.keysym.sym == SDLK_2)
{
}
break;
{
}
break;
default:
break;
}
}
}
{
}
delete fFont;
delete fInput;
return 0;
}
void ModifyProgress(void *iParam1, void *iParam2)
{
const int *id = (const int*)iParam1;
const int *op = (const int*)iParam2;
current = current + *op;
}
void PrintHelp()
{
char *sMsg;
sMsg = new char[1024];
strcpy(sMsg,"-----------------------------------------------------------\n");
strcat(sMsg," ");
strcat(sMsg,EXAMPLE_VERSION);
strcat(sMsg,"\n-----------------------------------------------------------\n\n");
strcat(sMsg," Press [ESCAPE] key to exit.\n");
strcat(sMsg," Press [1] to set the CTYPE_CENTER cursor pointer.\n");
strcat(sMsg," Press [2] to set the CTYPE_NORMAL cursor pointer.\n");
strcat(sMsg,"\n Runtime information is logged into 'GUI.log' file.\n");
strcat(sMsg,"\n");
#ifdef _WINDOWS
MessageBox(NULL,sMsg,"CRM32Pro SDK - HelpScreen",MB_OK);
#endif
#ifdef _LINUX
printf("CRM32Pro SDK - HelpScreen\n%s",sMsg);
#endif
delete[] sMsg;
}