Stratos: Punto de Encuentro de Desarrolladores

¡Bienvenido a Stratos!

Acceder

Foros





Startup Config Dialog & Crm32pro

Iniciado por , 11 de Octubre de 2005, 02:09:34 AM

« anterior - próximo »

 
 Heya. :) New topic:

  How do I add a simple startup config dialog (like on your downloadable pong example binaries) allowing a player to set the resolution, and other such options on startup???

  So far, I have failed miserably to add such a component. :) hehehe.

Warchief

 Hi Mike,
¿do you mean config menu?

Anyway, download pong source code (available at megastormsystems).
Its a lot of code:


// ---Carga el menu y prepara para lanzar el juego---
 done=0; bFlagDraw=true;
 while(!done)
 {
  // La primera vez o despues de volver de un juego pintamos todo e iniciamos musica
  // o si estamos en modo doublebuffer
  if((bFlagDraw) || (((screen->flags&SDL_DOUBLEBUF)==SDL_DOUBLEBUF)))
  {
   // Solo con bFlagDraw
   if(bFlagDraw)
   {
    IScreenFX->FadeImageA(sMenuBg,FADENORMAL);
    ISoundFX->MusicPlay(music_menu, 100); // La repite 100 veces  
       bFlagDraw=false;
   }
   SDL_BlitSurface(sMenuBg,NULL,screen,NULL);
         rRect.x=27;rRect.y=20;rRect.w=sMenuTitle->w; rRect.h=sMenuTitle->h;
      SDL_BlitSurface(sMenuTitle,NULL,screen,&rRect);
      rRect.x=133;rRect.y=578;rRect.w=sMenuInfo->w; rRect.h=sMenuInfo->h;
      SDL_BlitSurface(sMenuInfo,NULL,screen,&rRect);      
  }  
  // Actualizamos botones y volcamos pantalla    
  bID=IButton->Draw();
  ICursor->Draw();
  SDL_Flip(screen);
....
// Event listener goes here
// taking the action for the menu.
// For example calling to gameloop if you select start.
...
} // while !done


Of course you have to initialize the items before entering the loop:


 sMenuBg=IImage->Load(GFX_RESOURCE,"menubg",&hIPF);
 sMenuTitle=IImage->Load(GFX_RESOURCE,"menutitle",&hIPF);
 sMenuInfo=IImage->Load(GFX_RESOURCE,"menuinfo",&hIPF);
// Lot of init goes here
 bExitID=IButton->Load(GFX_RESOURCE,"bExit"); // Example of button
// Lot of init goes here

...


Direct link to Pong source code:
http://www.megastormsystems.com/download/S...-Sourcecode.rar
Comments are in spanish, but its pretty good that the code vars and methods are in english, so you will be able to understand them.

Tell us if you need more help.

TheAzazel

 Warchief gave you a lot of useful information. He used the library a few months ago(right now...I dont know), he  found a few bugs and requested to me a couple of features, so thanks him, I could fix and to add alpha per pixel support and so on.

He asked me about the same issue...  Could I use a config program like the SpacePong one? and yes, you could :). The CRM32Pro roadmap has an entry to port that program to java(we need multiplatform programs!) and to extend it to support new features(as glSDL). By the way, I dont have any problem to send you the full project of that config system. It compiles with Visual Studio (6 or any 200x version) and it has a very little instructions to modify and to fit on your project but is really easy to use.

So, if you want to try, let me know. Maybe if it works for you..I could upload it to the main web page...who knows! :P

   Sorry, I should have specified, it was a Windows Dialog (Like CDialog) box that popped up, also - it wasn't the example pong, it was the space pong in the Mini-Games section, but I assumed they were one in the same.

 Sorry about the confusion there :) Anywho, I have decided to take a less-o.s. specific route, being as that I am using SDL anyway, and coding a config menu would be less troublesome than coding one through.. say MFC.

 
 Also, thanks for the replies! :)

Warchief

Cita de: "Mike"Sorry, I should have specified, it was a Windows Dialog (Like CDialog) box that popped up, also - it wasn't the example pong, it was the space pong in the Mini-Games section, but I assumed they were one in the same.

 Sorry about the confusion there :) Anywho, I have decided to take a less-o.s. specific route, being as that I am using SDL anyway, and coding a config menu would be less troublesome than coding one through.. say MFC.
It is actually the same game.

I didnt know (=remember) it had the previous to game config dialog. Yeah i asked Aza for that config tool to be released (denied :P), but as he said it would be better if config dialog could be moved to Java (portability) before release, indeed.

Is there a dialog for the linux version right now Az?

TheAzazel

 Right now, there is not a config system for Linux, there is only one for Windows, therefor it is not released to public domain... that config system is the same as SpacePong has.

So, as many of you though. CRM32Pro and SDL are multiplatform so I will code a config system on Java language. I dont know too much about Java but I think it will not be a hard task.

As soon as I finish it, I will update web page.

Cheers

 
 That would be an awesome util to implement. :)

  I took the basic idea of a config file from the example pong source and modified it some.
 
  I actually wrote a wrapper class for crm32pro called CStdCrm32Pro that does all of the basic subsystem init, logging and config load/save/reset. All that is left to do is use the derived class, CStdGame, override CStdGame::Run() with your game code, put init code in the constructor, deinit code in the destructor, and add your includes directly to the CStdGame header.

  It also includes main.cpp and stdinc.h. Main.cpp doesn't need any extra code, as it just creates an instance of CStdGame and calls Run(). stdinc.h contains a define PROJECT_NAME, and includes crm32pro.h for you.

 It is a decent skeleton, avoids rewritting the basics over and over again, and with the config file, initializing crm32pro is customizable.

 Having a java confg dialog would be nice, especially if it could be used in the game code at the beginning, or as a seperate utility alltogether. (I could see both methods being used frequently for crm32pro games.)

 Ah. Not enough coding going on! Better get back to that.. see ya

Mike
 

TheAzazel

 The idea with java config is to output all settings to external file (to setup.cfg for example, as now) and after, a function of CRM32Pro will load all this parameters automatically, so if you have coded something like this and would you like to share it...i could add it to crm32pro.

see you Mike!

cheers

 
Well I could make it a seperate module-type of thing, a class or something. That's no problem.

The thing is, it only loads/saves & resets the config file. There is no GUI for it.

The point is, it's something you could do easily - and probably more efficiently, but if you're still interested, I wouldn't mind modifying and sharing the code at all, in fact I'd be honored.  :D


TheAzazel

 Ok, no problem then...
I was playing a bit with Java to develop a fully customizable Config system for CRM32Pro... but finally, I decided to use CRM32Pro with its GUI functions to create a very customizable and portable executable.

The idea is: EditorDPF will support a new tab..."Packed files" where you could add/remove/modify any file (this allow you to add .ini,.cfg, any script languages or whatever you want to your DPF). If the file is ASCII..you will be able to modify directly from EditorDPF...
So, a setup.cfg will be added to DPF, with ASCII format. CRM32Pro will parse this file and to initialize all systems according to that information.
And the Config System will extract all its graphics stuff from a DPF(so you could change everything on easy way) and it will work with the previous setup.cfg.

I think this is the best way to get a fully customizable and portable config system, any other idea, will be welcomed :)

As soon as I finish this system, I will notice you...

so...happy coding!!!

Warchief

 Hey Aza,.

If i have understood, you plan to include the .ini or .cfg to the pak.

If so, i dont think thats a good idea. Think .cfg may be changed at execution time (before playing). If someone releases a game and players want to change configuration (change resolution, mouse speed, any flag...) you have to open pack with EditorDPF!, which is not the best way for the player.

Im thinking about a custom application (java standalone one) with common properties (resolution, fullS/windowed, gamma, mouse speed...) and a customizable module defined by xml (like key configuration, pads, etc.).

That module could be represented by a list of Param Value. If you double click over a item, a SetNewValue dialog may appear.

Maybe an example of xml

<?xml version bla bla bla ?>

 <AdditionalConfigList>
     <!-- Section  Param Value -->

     <!-- Pad Section -->
     <Pad param="Right"  value="RightAnalog"/>
     <Pad param="Left"    value="LeftAnalog"/>

     <!-- Key Section -->
     <Key param="RotateCamRight"  value="Supr"/>
     <Key param="RotateCamLeft"  value="Insert"/>

 </AdditionalConfigList>





The common properties could be included in this xml or allow a different .ini file; so developer could choose whether to use the xml or not.

Users claim for a crm32 xml parser  (ole)

(Well, a lot of work ahead  ;) )

 
 Hm. But then again, having someone build there own config system isn't hard, especially if they have years of c++ knowledge, unlike my one month of c++.

 All-in-All - A user of crm32pro could easily build a config for themselves. I would just like an example of how to merge MFC with crm32pro.  :)  

 Secondly, I think it would be AWESOME if "other" files could be added to .dpf's. I wouldn't put my config inside it, but it would be great for scripts! YOU should definitely add that to editordpf!!!!!


TheAzazel

 Warchief: a xml parser could be a cool addon but... right now it will not possible to implement it, as you said, is too much work and I have a lot of things to do. But, you could use any other xml parser and to store the xml files on DPF (yes! I have ready a fully working support to add files to any DPF using the Editor)


Whatever I meant on my last post was to use a DPF to store a .cfg (a file with ASCII format) and a special software, Config System(Im working on it, it will be multiplatform and fully customizabke) will allow to the user to set a desired resolution, sound, etc... . And finally, CRM32Pro will have new methods to load this configuration from a external file or from a file packed into a DPF.

It is the same system as SpacePong config but with the difference that the config system will be portable, customizable, .cfg fully editable with text editor and you could pack it into a DPF...

Mike, to merge CRM32Pro with MFC you only have to include "crm32pro.h", link against crm32pro.lib and forget sdlmain.lib... everything works on the same way as without MFC :)

Do you understand better the on coming Config System? I hope so!

cheers

P.S.: I am very sleppy so maybe nobody understand me haha

Warchief

 I dont think a years of c++ dev is the intended user of crm32pro. I think most of the people looking for easy 2D libs are always those who want to start developing easy and quick games. Dont you agree?

Moreover, those using a portable lib wouldnt probably like to build an OS dependant config application.

Anyway, i think its a lot of work; one way or another. XD

Hadnt read Aza's post.

Yeah, with xml parser i was thinking about a easy crm32pro xml reader api, to avoid looking for any parser. (Just a few onStart(), onElement(), onStop() methods).

Stop library development, and use it to create a brand new game; it has been a lot of time since your last game, hasn't it?  :P  :P






Stratos es un servicio gratuito, cuyos costes se cubren en parte con la publicidad.
Por favor, desactiva el bloqueador de anuncios en esta web para ayudar a que siga adelante.
Muchísimas gracias.