Text colors using txt file ?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Question_dev
Posts: 88
Joined: Fri Aug 24, 2007 8:23 pm

Text colors using txt file ?

Post by Question_dev »

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: Select all

printTextScreen(0, 20, "Menu1");
printTextScreen(0,  0, "Menu2");

And for example the color txt file (colors are RGB):

Code: Select all

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)
edepot
Posts: 111
Joined: Sat Apr 09, 2005 3:39 pm

Post by edepot »

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.
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

Lol, I really think you are funny, quoted from my iso/cso thread:
Question_dev wrote:PIRATA NERVo == COPY/PASTER

He ask every code for his app on forums/sites/tutorials/source code

This code comes from : http://www.pspcrazy.com/index.php?page=Story&id=736

Load pbp => this site

Filbrowser => slasher

etc....
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.
Image
Upgrade your PSP
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

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-w ... .zip?hl=en
PosX100
Posts: 98
Joined: Wed Aug 15, 2007 1:02 am

Post by PosX100 »

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
Question_dev
Posts: 88
Joined: Fri Aug 24, 2007 8:23 pm

Post by Question_dev »

@edepot : Yeah, it would be very nice if you release a library
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

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.
Question_dev
Posts: 88
Joined: Fri Aug 24, 2007 8:23 pm

Post by Question_dev »

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...
PosX100
Posts: 98
Joined: Wed Aug 15, 2007 1:02 am

Post by PosX100 »

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++)
Question_dev
Posts: 88
Joined: Fri Aug 24, 2007 8:23 pm

Post by Question_dev »

Sorry, but i can't make this by myself :(

Thanks for the help anyway..
PosX100
Posts: 98
Joined: Wed Aug 15, 2007 1:02 am

Post by PosX100 »

:(
"First try , then cry"..
User avatar
Wally
Posts: 663
Joined: Mon Sep 26, 2005 11:25 am

Post by Wally »

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
Post Reply