| View previous topic :: View next topic |
| Author |
Message |
Question_dev
Joined: 24 Aug 2007 Posts: 88
|
Posted: Sun Mar 30, 2008 12:09 am Post subject: Text colors using txt file ? |
|
|
Hi,
I'm trying to code an app that displays text.
BUT i want to set the color of each "block of text" using a cfg/txt file.
So i have the text :
| Code: | printTextScreen(0, 20, "Menu1");
printTextScreen(0, 0, "Menu2");
|
And for example the color txt file (colors are RGB):
| Code: |
MENU1 = 12, 13, 15
MENU2 = 0, 0, 0
|
Thanks in advance
Please help me out of this...
(giving source code from an app that uses this to is also helpful) |
|
| Back to top |
|
 |
edepot
Joined: 09 Apr 2005 Posts: 111
|
Posted: Sun Mar 30, 2008 4:52 am Post subject: |
|
|
Well, there are many ways to approach this.
Since I am doing something similar (but probably not immediately), you can use this method... (you may need to brainstorm a bit, but this is a method that just came up while reading your post)
<colors>
<001>5,6,7
<002>11,22,33
<003>55,66,77
<text>
<t1>This be the text block one<nl>
More text
<t2>This is block two
more info
more more info
<t3>
code:
print("t1","002",initialScreenInfo);
if you are interested in using the above method, I can release the library you can link to. otherwise, feel free to use the above method :)
Look in the PSP Game forums if it is ever implemented in the future:
http://www.edepot.com/game.html
Last edited by edepot on Sun Mar 30, 2008 5:10 am; edited 2 times in total |
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Sun Mar 30, 2008 4:57 am Post subject: |
|
|
Lol, I really think you are funny, quoted from my iso/cso thread:
Did you even look at you?
looool. I did some research about me and I can't find any more places where I ask for help besides PSP-Hacks (the last time I asked for help there, was on last summer) and this site, I only asked for help 2 or 3 times.
Talking about you..you asked for help more than 5 (on this site, I don't know about the other sites)
Please, only because I don't give you my code which took me a lot of work, don't be rude to me, that's not good. _________________
Upgrade your PSP |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Sun Mar 30, 2008 9:19 am Post subject: |
|
|
Sigh. Why do some "devs" always post a new thread asking about basic programming instead of searching or looking at code already out? Seriously, it doesn't say much about a programmer when they have to ask how to read values from a text file. While printing in color IS a valid PSP question, there are so many examples already out (and threads on it here) that asking just makes them look stupid and/or lazy.
That said, I'll chip in this bit of help: Doom for the PSP has code showing how to save/load from a text config file, and how to print in color using both the debug printing and intraFont.
http://groups.google.com/group/chilly-willys-ice-flow/web/psp-doom-v1.4.zip?hl=en |
|
| Back to top |
|
 |
PosX100
Joined: 15 Aug 2007 Posts: 98
|
Posted: Sun Mar 30, 2008 6:58 pm Post subject: |
|
|
Text file:
MyColor1 = r[255] g[255] b[255]
Reading:
Basic C++/C IO(WHICH has nothing to do with this forum):
struct COLOR
{
int r,g,b
};
function COLOR* get_color_(const std::string& f,const std::string& str)
open file f
while reading file..
read line...
remove white space
if string *STR* found in line
COLOR c;
c.r = parse line starting from "r[" until "]"
c.g = parse line starting from "g[" until "]"
c.b = parse line starting from "b[" until "]"
return &c...
Usage:
COLOR* c = get_color_("theme.txt","MyColor1");
To avoid opening the file each time you need to read a color:
Create a class:
-load the data
-parse data
-get whatever you want |
|
| Back to top |
|
 |
Question_dev
Joined: 24 Aug 2007 Posts: 88
|
Posted: Mon Mar 31, 2008 9:36 am Post subject: |
|
|
| @edepot : Yeah, it would be very nice if you release a library |
|
| Back to top |
|
 |
Art
Joined: 09 Nov 2005 Posts: 647
|
Posted: Mon Mar 31, 2008 4:59 pm Post subject: |
|
|
Are you blind? There's one right above you.
Add in a_noob's config file parser from pspprogramming.com and it is complete. _________________ If not actually, then potentially. |
|
| Back to top |
|
 |
Question_dev
Joined: 24 Aug 2007 Posts: 88
|
Posted: Mon Mar 31, 2008 6:44 pm Post subject: |
|
|
| Art wrote: | Are you blind? There's one right above you.
Add in a_noob's config file parser from pspprogramming.com and it is complete. |
I saw
But i'm not a 'good' coder like you...
I understand it how to do now, but not how to code... |
|
| Back to top |
|
 |
PosX100
Joined: 15 Aug 2007 Posts: 98
|
Posted: Mon Mar 31, 2008 8:13 pm Post subject: |
|
|
www.google.com :
"C reading a file line by line" or "C++ reading a file line by line"
then
"C find substring" or "C++ find substring"
then
"C parse string" or "C++ parse string"
then
"C convert string to integer"(well,the function is atoi()) or "C++ convert string to integer"
And a last hint:
A string is a list of characters , meaning that:
char * str="hey hey"
std::string str ="hey hey"
=
str[0] = h
str[1] = e
str[2] = y
str[3] = white space :)
str[4] = h
str[5] = e
str[6] = y
str[7] ='\0'
to get the length of a string:
use strlen()(C) or str.length()(C++) |
|
| Back to top |
|
 |
Question_dev
Joined: 24 Aug 2007 Posts: 88
|
Posted: Mon Mar 31, 2008 8:41 pm Post subject: |
|
|
Sorry, but i can't make this by myself :(
Thanks for the help anyway.. |
|
| Back to top |
|
 |
PosX100
Joined: 15 Aug 2007 Posts: 98
|
Posted: Mon Mar 31, 2008 10:05 pm Post subject: |
|
|
"First try , then cry".. |
|
| Back to top |
|
 |
Wally

Joined: 26 Sep 2005 Posts: 672
|
Posted: Mon Mar 31, 2008 10:37 pm Post subject: |
|
|
| Question_dev wrote: | | Art wrote: | Are you blind? There's one right above you.
Add in a_noob's config file parser from pspprogramming.com and it is complete. |
I saw
But i'm not a 'good' coder like you...
I understand it how to do now, but not how to code... |
Art said he wasnt a good coder to me :P
Im in the same boat as you Question_dev. I found the best way to start to learn is to read a book then attempt to port over a few SDL games to get the hang of makefiles / error messages then work on debugging with PSPLink and then programming the keys into PSP with analog support and attempt something major.. (Im not up to the challenging bit yet but im not far off)
Its worth every step of this, there will always be a developer on your side to try and help understand every concept! You just have to be polite and perhaps at the end of the tutorial work on something with the dev or donate some money. w/e
I have enough trouble keeping up to HardHats Demands as it is :P
Wally |
|
| Back to top |
|
 |
|