Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / text problems

Author
Message
Fox Dark Master
20
Years of Service
User Offline
Joined: 20th Jul 2004
Location: Portugal
Posted: 23rd Mar 2010 21:43 Edited at: 23rd Mar 2010 22:11
Hellos everyone, it's been a long time since i've posted here
I'm doing a rpg'ich like game and i was coding a simple function to save / load the game settings like resolution, fullscreen, effects, etc...

The problem is that i've tried all commands to write stuff in a file and the only one who didn't give me error messages were the string ones ( which is annoying using the funcion itoa all the time ). The thing is: is there any particular way to use the file commands to save and load integer values of a file or should I use the stdio library commands to write stuff?

Happy coding

P.s: It's a file problem but i can't find the button to change the topic message >.>
haliop
User Banned
Posted: 25th Mar 2010 08:07
well , first you have the simple DarkGDK method which worked out for me when i made a 2D map editor if i had the code i would have post it , but i lost it
check the DarkGDK.CHM (refrence)
well the idea is:

int resulotionX , int resulotionY
resulotionX = 1600 ;(for example)
resulotionY = 900 ;

dbMakeFile(##,"BLABLA.whatever")
dbWriteToFile(##,resulotionX) // writetofile writes an Integer Value

you also have WriteString or Floats , check the refrence.

then when you want to load ,
you ,
dbOpenToRead(##) // or something like that i can remmber all from memory

dbReadFromFile()
i think that after this command was done , it will jump to the next line in that file, and if you use it again it will read the second line and jump again , so its pretty simple to use
after you have opened a file

just :

resulotionX = dbReadFromFile(##); // first line
resulotionY = dbReadFromFile(##); // second line
and so on
just remmber to do it in the same order as when you save the files
its all pretty simple actually.
Cetobasilius
14
Years of Service
User Offline
Joined: 29th Dec 2009
Location: Mexico
Posted: 27th Mar 2010 00:36
dark coder would suggest you use fstream and iostream, since dark gdks file commands do work, but are prone to memory leaks (thats what i understood) http://www.cplusplus.com/doc/tutorial/files/

hi
Fox Dark Master
20
Years of Service
User Offline
Joined: 20th Jul 2004
Location: Portugal
Posted: 27th Mar 2010 17:09 Edited at: 27th Mar 2010 17:26
thank you all for the answers
I was getting the values from the file in a wrong way, i'm used to the C way


About the iostream... i really prefer the stdio lib, it looks more "clean" and simple to me. If I can't solve this little problems or if i find out it's really more safe to use stdio or the iostream i'll use one of them

Another thing,
when i write the values to "config.conf" it will remain empty. Maybe it's something i miss:



the first function to be called is void settings_load( void )

P.S.

Even with this simple little test:

still gives an empty file
Fox Dark Master
20
Years of Service
User Offline
Joined: 20th Jul 2004
Location: Portugal
Posted: 27th Mar 2010 20:55
Well i end up using the stdio lib to handle files

Use it if you find usefull

I'd like to add a feature to place the application's windows in the middle of the screen but db doesn't have a command to get the screen resolution ( at least by default ) x)
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 27th Mar 2010 21:12
thats the best way, its simple and handy, i always use it

Pilz X Schizo
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Massachusetts, USA
Posted: 27th Mar 2010 21:34
I did a quick search of the fourms and found these commands to get the desktop resolution.

int sWidth = GetSystemMetrics(SM_CXSCREEN);
int sHeight = GetSystemMetrics(SM_CYSCREEN);

then you could just do this...

int sWidth = (GetSystemMetrics(SM_CXSCREEN) - dbScreenWidth()) / 2;
int sHeight = (GetSystemMetrics(SM_CYSCREEN) - dbScreenHeight()) / 2;

...to get the position that will make the window centered.
Fox Dark Master
20
Years of Service
User Offline
Joined: 20th Jul 2004
Location: Portugal
Posted: 27th Mar 2010 22:04 Edited at: 27th Mar 2010 22:39
@Hassan
Aren't you the one who did some improvements in text commands?

@Pilz X Schizo
that is almost what i want except i saw a better version hours ago but i lost the page x) thanks anyways if i find it i'll post in here

ahh, and i use to think like:
( desktop Width or Height / 2 ) - ( window Width or Height / 2 )
didn't recall that way thanks

Edit 1:
Found a dll with some usefull commands like DesktopWidth / Heigh and so
http://forum.thegamecreators.com/?m=forum_view&t=32355&b=1
Didn't try it yet but hopefully it'll do just fine
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 28th Mar 2010 15:08
Quote: "
@Hassan
Aren't you the one who did some improvements in text commands?
"


i think so, why?

Fox Dark Master
20
Years of Service
User Offline
Joined: 20th Jul 2004
Location: Portugal
Posted: 28th Mar 2010 15:10
just checking, i'll need that later :3

Login to post a reply

Server time is: 2024-10-02 03:40:06
Your offset time is: 2024-10-02 03:40:06