April 29, 2024, 07:53:49 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


An Aurora game - help needed

Started by Rock Ridge Farm (Larry), May 14, 2006, 06:55:57 PM

Previous topic - Next topic

0 Members and 4 Guests are viewing this topic.

Rock Ridge Farm (Larry)

I have written the core of a game - now I  need to add the fancy screen stuff.
I am lost here.
I want a window screen that has the following structure:
================================================
!                                                                        ! Scrolling                    !
!                                                                        ! Text I/O                   !
!                                                                        ! Area                         !
!                                                                        !                                !
!                                                                        !                                !
!                                                                        !                               !
!                                                                        !                               !
!                                                                        !                               !
! 2d Display Area                                                  !                               !
!                                                                        !                               !
!                                                                        !                               !
!                                                                        !                               !
!                                                                        !                               !
!                                                                        !                               !
!                                                                        !                               !
!                                                                        !==============!
!                                                                        ! Text Display              !
!                                                                        ! Area                        !
!                                                                        !                                !
!                                                                        !                                !
!                                                                        !                                !
!                                                                        !                                !
================================================

Anyone care to help?

Parker

I'm no good with graphics, which is why I don't do games. But yeah, I see what you mean. I don't really have the time to come up with a demo, and I've never used Aurora's 2D classes, but here's the idea.

In a game you're redrawing everything all the time. So it's not like you have to worry about "Oh no, how do I scroll this?" You need to have a bunch of lines of text (an array is a good method for storing lines), then based on the scroll bar's position (you'll have to render it yourself, except if I remember correctly you can use windows controls on a 2D screen), you'll draw however many lines you can fit. There's probably a GetTextSize method in the window class (I haven't used them much, only console stuff :-\) that you can calculate the height with. With an array it's easy, because at scrollbar position 0, you draw lines[0] through however many you can put there. At position 1, you draw lines[1] through lines[n], etc.

Input, again, you can use a windows text box, so you don't have to make your own. But if you do end up creating your own controls, I can help you as long as you ask after 2 weeks, I'm not free until then.

Text display area, pretty much the same as the scrolling area, just render as many lines as you can.

2D display area, just do what you normally do. Render sprites, background, etc.

Ionic Wind Support Team

Depends on whether your building a windows mode or full screen mode.

If it is a windowed mode 2D application then you can combine both 2D and GUI elements to gether in a parent window.  Create a parent window, the 2D window with no caption blonging to the parent, an edit control can serve as the text display area.  You can use a rich edit control for the text i/o area if you want things like colored text for each player.

For a full screen application your stuck building your own controls from scratch and dividing up the screen area as needed.  DX full screen and the GUI don't play together well.  Which makes sense since your looking at a memory buffer on the video card and Windows is for the most part out of the picture when rendering.

Ionic Wind Support Team

Rock Ridge Farm (Larry)

I think this is a bit more simple minded than you may think.
It is kind of a RPG. You input a decision and actions occur in the 2D area.
The 2D area is a 'scope' like display that can be zoomed in a range of 1-10.
It will display the current status of a fleet of ships and is updated based on paramater changes
entered in the I/O window. It can be set to an automatic update till an event or just stepped as commands
are entered. It will reflect the status of up to 400 elements at a given time.
This is a game I wrote 20+ years ago using curses on a Unix Box.
It started out as a simulation of the Battle of Midway.
(Interesting note - The US never wins. Had 2 major accidental issues occured the US  would not have won that battle. A radio failure on a scout plane and a catapult launch failure on a ship.).
Over the years I modified and updated it and turned it into a space game called SB Vega.
I also modified it to at least give the good guys a chance.
I need to replace the curses part with a window interface.

Rock Ridge Farm (Larry)

It is the 'How do make a window'  type question.
I have spent all of my life in the Unix world - I do not know krap about windows or how to code them.
I am looking for a kick start on building the screen. Guess I am too old to have the explorer nature anymore.

Zen

Larry. This is something i had for an idea for CCL. Only at the time i started it there was no 2D. As i am a bit busy at the moment there is not much i can do but i am planning on making a set of 2D GUI classes for controls and interfaces so to speak. The main reason i want to do this is because i wanted to do it for IBasic but never had time.

It will be great if users can add controls and windows with minimize and maximize capabilities within the 2D. I dont mean actual windows ones but custom designed ones.

Lewis

Rock Ridge Farm (Larry)

Still busy - I am quitely waiting.

Parker

As a developer, I think you know what's taking up most of Lewis' time ;)

Rock Ridge Farm (Larry)

Zumwalt or Kryton9 - with all the stuff you have been doing - would one of you consider helping here?
I am still basically at 0.
Have not had much time - let work and farm stuff get in the way.

J B Wood (Zumwalt)

Just saw this, been busy in the 3d world.
I'll take a look over this tonight and some of the 2d examples to see if I can assist you.
Rules on 2d are different that 3d, but only because of the lacking axis.

kryton9

August 04, 2006, 10:59:35 AM #10 Last Edit: August 04, 2006, 11:01:35 AM by kryton9
Larry, I thought I would get into 2d this weekend, so I hope to be able to help you soon. Right now don't know, but I am sure it will be fun trying to get it going.

kryton9

August 04, 2006, 12:51:25 PM #11 Last Edit: August 04, 2006, 01:09:36 PM by kryton9
Just to get this thing going here is something I put together today.

Not sure if separate windows is ok, the only way I could do it easily


// Based off of the breakout example
// for the 2d screen stuff

#typedef UINT unsigned int;
DECLARE IMPORT,timeGetTime(),UINT;


//Global variables
int width;
int height;
int border_size;
int num_lines;
int topspace;
int bottomspace;
unsigned int border_color;
int fps;
int exit_game;
int mElapsed,mTimer,lastY;
double mAdjust;
C2DScreen *pScreen;

global sub main()
{
Setup();
//Scroll text screen
CWindow w1,w2;
w1.Create(width+4,0,300,height*.6,AWS_AUTODRAW | AWS_VISIBLE,0,"",0);
w1.WriteText(5,20,"This will be the scrollable text");

//text screen
w2.Create(width+4,height*.6,300,height*.4,AWS_AUTODRAW | AWS_VISIBLE,0,"",0);
w2.WriteText(5,20,"This will be the text screen");

//2D screen create
pScreen = new(C2DScreen,1);
pScreen->CreateWindowed(0,0,width+4,height,AWS_VISIBLE|AWS_POPUP|AWS_CAPTION,0,"2D Multi Screen Test - ESC to exit",0);
pScreen->SetStretchedFlip(FALSE);
sz = pScreen->GetClientRect();
width = sz.right;
height = sz.bottom;
pScreen->SetFocus();
C2DSurface *back = pScreen->GetBack();

//turn off the cursor
pScreen->SetCursor(CS_CUSTOM,0);// if you want the cursor in the 2d screen, comment out this line
//Set our font and text colors
pScreen->SetFont("Ariel",12,600);
pScreen->FrontPen(RGB(192,192,255));
pScreen->DrawMode(TRANSPARENT);


mTimer = timeGetTime();
point tx;
DO
{
back->Fill(0);
ShowStatus();
DrawBorder();

//show game over graphics
tx = pScreen->GetTextSize("A line of text to see what can be placed where.");
pScreen->WriteText( width/2 - tx.x/2,height/2 - tx.y/2, "A line of text to see what can be placed where.");
//ESC to exit at any time

IF( GetKeyState(0x1B)) exit_game = TRUE;


//target 75 frames per second for ball movement.
mElapsed = timeGetTime() - mTimer;
mTimer = timeGetTime();
mAdjust = mElapsed / 13.3333;
fps = pScreen->Flip(1);
//mAdjust = 1

} UNTIL exit_game = TRUE;
//clean up and end
pScreen->CloseScreen();
delete pScreen;
return 0;
}

SUB Setup
{
//Our initial settings
width = 640;
height = 480;
border_size = 7;
num_lines = 10;
topspace = 40 + border_size;
bottomspace = border_size;
border_color = RGB(192,192,255);
fps = 0;
exit_game = FALSE;
}

SUB DrawBorder()
{
C2Dsurface *back = pScreen->GetBack();
back->DrawFilledRect( 0,0,width,border_size,border_color);// top
back->DrawFilledRect( 0,height-border_size,width,border_size,border_color);// bottom
back->DrawFilledRect( 0,0,border_size,height,border_color);// left
back->DrawFilledRect( width-border_size,0,border_size,height,border_color);// right
RETURN;
}

SUB ShowStatus()
{
pScreen->WriteText( border_size+10,border_size+10,"This is the 2D screen area");
pScreen->WriteText( border_size+10,45,"FPS: "+str$(fps));
RETURN;
}

kryton9

August 04, 2006, 01:23:59 PM #12 Last Edit: August 04, 2006, 01:27:08 PM by kryton9
Ok, this one is probably more what you wanted :)

Escape key to exit the program.
// Windows Program
// Second Version
// Based off of the breakout example
// for the 2d screen stuff

#typedef UINT unsigned int;
DECLARE IMPORT,timeGetTime(),UINT;


//Global variables
int width;
int height;
int border_size;
int num_lines;
int topspace;
int bottomspace;
unsigned int border_color;
int fps;
int exit_game;
int mElapsed,mTimer,lastY;
double mAdjust;
C2DScreen *pScreen;

global sub main()
{
Setup();
//Scroll text screen
CWindow w1,w2;
w1.Create(width+4,0,300,height*.6,AWS_AUTODRAW | AWS_VISIBLE | AWS_POPUP | AWS_VSCROLL ,0,"",0);
w1.setwindowcolor(rgb(Rand(255),Rand(255),Rand(255)));
w1.DrawMode(TRANSPARENT);
w1.WriteText(5,20,"This will be the scrollable text");

//text screen
w2.Create(width+4,height*.6,300,height*.4,AWS_AUTODRAW | AWS_VISIBLE | AWS_POPUP ,0,"",0);
w2.setwindowcolor(rgb(Rand(255),Rand(255),Rand(255)));
w2.DrawMode(TRANSPARENT);
w2.WriteText(5,20,"This will be the text screen");

//2D screen create
pScreen = new(C2DScreen,1);
pScreen->CreateWindowed(0,0,width+4,height,AWS_VISIBLE|AWS_POPUP,0,"2D Multi Screen Test - ESC to exit",0);
pScreen->SetStretchedFlip(FALSE);
sz = pScreen->GetClientRect();
width = sz.right;
height = sz.bottom;
pScreen->SetFocus();
C2DSurface *back = pScreen->GetBack();

//turn off the cursor
pScreen->SetCursor(CS_CUSTOM,0);// if you want the cursor in the 2d screen, comment out this line
//Set our font and text colors
pScreen->SetFont("Ariel",12,600);
pScreen->FrontPen(RGB(192,192,255));
pScreen->DrawMode(TRANSPARENT);


mTimer = timeGetTime();
point tx;
DO
{
back->Fill(0);
ShowStatus();
DrawBorder();

//show game over graphics
tx = pScreen->GetTextSize("The mouse is hidden on this screen, but not on the others.");
pScreen->WriteText( width/2 - tx.x/2,height/2 - tx.y/2, "The mouse is hidden on this screen, but not on the others.");
//ESC to exit at any time

IF( GetKeyState(0x1B)) exit_game = TRUE;


//target 75 frames per second for ball movement.
mElapsed = timeGetTime() - mTimer;
mTimer = timeGetTime();
mAdjust = mElapsed / 13.3333;
fps = pScreen->Flip(1);
//mAdjust = 1

} UNTIL exit_game = TRUE;
//clean up and end
pScreen->CloseScreen();
delete pScreen;
return 0;
}

SUB Setup
{
//Our initial settings
width = 640;
height = 480;
border_size = 7;
num_lines = 10;
topspace = 40 + border_size;
bottomspace = border_size;
border_color = RGB(192,192,255);
fps = 0;
exit_game = FALSE;
}

SUB DrawBorder()
{
C2Dsurface *back = pScreen->GetBack();
back->DrawFilledRect( 0,0,width,border_size,border_color);// top
back->DrawFilledRect( 0,height-border_size,width,border_size,border_color);// bottom
back->DrawFilledRect( 0,0,border_size,height,border_color);// left
back->DrawFilledRect( width-border_size,0,border_size,height,border_color);// right
RETURN;
}

SUB ShowStatus()
{
pScreen->WriteText( border_size+10,border_size+10,"This is the 2D screen area");
pScreen->WriteText( border_size+10,45,"FPS: "+str$(fps));
RETURN;
}

kryton9

August 04, 2006, 01:43:29 PM #13 Last Edit: August 04, 2006, 03:08:01 PM by kryton9
Sometimes with the random colors you couldn't see the test so small change there
and now working on getting the scrolling working. It isn't at the moment, not sure why.

//Windows Program
// Fourth Version
// Based off of the breakout example
// for the 2d screen stuff

#typedef UINT unsigned int;
DECLARE IMPORT,timeGetTime(),UINT;


//Global variables
int width;
int height;
int border_size;
int num_lines;
int topspace;
int bottomspace;
unsigned int border_color;
int fps;
int exit_game;
int mElapsed,mTimer,lastY;
double mAdjust;
C2DScreen *pScreen;


global sub main()
{
Setup();
//Scroll text screen
CWindow w1,w2;
w1.Create(width+4,0,200,height*.6,AWS_AUTODRAW | AWS_VISIBLE | AWS_POPUP | AWS_VSCROLL ,0,"",0);
w1.setwindowcolor(rgb(100,Rand(255),Rand(255)));
w1.DrawMode(TRANSPARENT);
w1.WriteText(5,20,"This will be the scrollable text");
for(x=0;x<100;x++)
{
w1.WriteText(5,80+(x*12),"see if this window will scroll"+NumToStr(x));
}
//text screen
w2.Create(width+4,height*.6,200,height*.4,AWS_AUTODRAW | AWS_VISIBLE | AWS_POPUP ,0,"",0);
w2.setwindowcolor(rgb(100,Rand(255),Rand(255)));
w2.DrawMode(TRANSPARENT);
w2.WriteText(5,20,"This will be the text screen");

//2D screen create
pScreen = new(C2DScreen,1);
pScreen->CreateWindowed(0,0,width+4,height,AWS_VISIBLE|AWS_POPUP,0,"2D Multi Screen Test - ESC to exit",0);
pScreen->SetStretchedFlip(FALSE);
sz = pScreen->GetClientRect();
width = sz.right;
height = sz.bottom;
pScreen->SetFocus();
C2DSurface *back = pScreen->GetBack();

//turn off the cursor
pScreen->SetCursor(CS_CUSTOM,0);// if you want the cursor in the 2d screen, comment out this line
//Set our font and text colors
pScreen->SetFont("Ariel",12,600);
pScreen->FrontPen(RGB(192,192,255));
pScreen->DrawMode(TRANSPARENT);


mTimer = timeGetTime();
point tx;
DO
{
back->Fill(0);
ShowStatus();
DrawBorder();

//show game over graphics
tx = pScreen->GetTextSize("The mouse is hidden");
pScreen->WriteText( width/2 - tx.x/2,height/2 - tx.y/2, "The mouse is hidden");
tx = pScreen->GetTextSize("on this screen, but");
pScreen->WriteText( width/2 - tx.x/2,height/2 - tx.y/2+20, "on this screen, but");
tx = pScreen->GetTextSize("not on the others.");
pScreen->WriteText( width/2 - tx.x/2,height/2 - tx.y/2+40, "not on the others.");
//ESC to exit at any time

IF( GetKeyState(0x1B)) exit_game = TRUE;


//target 75 frames per second for ball movement.
mElapsed = timeGetTime() - mTimer;
mTimer = timeGetTime();
mAdjust = mElapsed / 13.3333;
fps = pScreen->Flip(1);
//mAdjust = 1

} UNTIL exit_game = TRUE;
//clean up and end
pScreen->CloseScreen();
delete pScreen;
return 0;
}

SUB Setup
{
//Our initial settings
width = 440;
height = 480;
border_size = 7;
num_lines = 10;
topspace = 40 + border_size;
bottomspace = border_size;
border_color = RGB(192,192,255);
fps = 0;
exit_game = FALSE;
}

SUB DrawBorder()
{
C2Dsurface *back = pScreen->GetBack();
back->DrawFilledRect( 0,0,width,border_size,border_color);// top
back->DrawFilledRect( 0,height-border_size,width,border_size,border_color);// bottom
back->DrawFilledRect( 0,0,border_size,height,border_color);// left
back->DrawFilledRect( width-border_size,0,border_size,height,border_color);// right
RETURN;
}

SUB ShowStatus()
{
pScreen->WriteText( border_size+10,border_size+10,"This is the 2D screen area");
pScreen->WriteText( border_size+10,45,"FPS: "+str$(fps));
RETURN;
}


Rock Ridge Farm (Larry)

Played with it a bit today - will let you know how much trouble I get into.
Thanks for the help - I am sure I will need much more.

kryton9

I think you will need to make your own class with a dialog to handle the scrolling text with input, I just didn't want to make the code overly complicated with all of that stuff, and besides not sure if I could do it anyways :)

I will work on it tonight just for fun, hope to see the start of your game soon. Will be glad to help if I can :)

Rock Ridge Farm (Larry)

I have the game working in char mode on my linux box - now to re-code in Aurora.
Slightly less than 2000 lines of code to convert.

kryton9

If you figure out a routine to check the users video setting so that the program can pick the maximum that it could run in let me know.

That would be very useful :)  Good luck on the conversion. That will be a big job for sure, but have fun.

kryton9

August 06, 2006, 12:31:43 AM #18 Last Edit: August 06, 2006, 12:47:40 AM by kryton9
I made good progress on getting the type of screen working.

Can't get settext to work from ccontrol with the richedit and also the setcolor command.
You can use the control and I get no errors with what i wrote, so not sure what is happening.

I want to be able to change the richedit background to match the window's color it is in and also to put
some text into it. I commented where the lines are with <<<<<<<<<<<

// Windows Program
// Fifth Version
// Based off of the breakout example
// for the 2d screen stuff

#typedef UINT unsigned int;
DECLARE IMPORT,timeGetTime(),UINT;
class MyWindow : CWindow
{
declare MyWindow();
declare _MyWindow();
declare virtual OnClose(),int;
declare virtual OnControl(int nID, int nNotifyCode, unsigned int hControl),int;
declare virtual OnCreate(),int;
CRichEdit rEdit;
}

//Global variables
int width;
int height;
int border_size;
int num_lines;
int topspace;
int bottomspace;
unsigned int border_color;
int fps;
int exit_game;
int mElapsed,mTimer,lastY;
double mAdjust;
MyWindow *pw1;
CWindow *pw2;
C2DScreen *pScreen;

global sub main()
{
Setup();
//Scroll text screen
pw1=new(MyWindow,1);
pw1->Create(width+4,0,200,height*.6,AWS_AUTODRAW | AWS_VISIBLE | AWS_POPUP ,0,"",0);
w1Txt();
//text screen
pw2=new(CWindow,1);
pw2->Create(width+4,height*.6,200,height*.4,AWS_AUTODRAW | AWS_VISIBLE | AWS_POPUP ,0,"",0);
w2Txt();
//2D screen create
pScreen = new(C2DScreen,1);
pScreen->CreateWindowed(0,0,width+4,height,AWS_VISIBLE|AWS_POPUP,0,"2D Multi Screen Test - ESC to exit",0);
pScreen->SetStretchedFlip(FALSE);
sz = pScreen->GetClientRect();
width = sz.right;
height = sz.bottom;
pScreen->SetFocus();
C2DSurface *back = pScreen->GetBack();

//turn off the cursor
pScreen->SetCursor(CS_CUSTOM,0);// if you want the cursor in the 2d screen, comment out this line
//Set our font and text colors
pScreen->SetFont("Ariel",12,600);
pScreen->FrontPen(RGB(192,192,255));
pScreen->DrawMode(TRANSPARENT);

mTimer = timeGetTime();
point tx;
DO
{
back->Fill(0);
ShowStatus();
DrawBorder();

//show game over graphics
tx = pScreen->GetTextSize("The mouse is hidden");
pScreen->WriteText( width/2 - tx.x/2,height/2 - tx.y/2, "The mouse is hidden");
tx = pScreen->GetTextSize("on this screen, but");
pScreen->WriteText( width/2 - tx.x/2,height/2 - tx.y/2+20, "on this screen, but");
tx = pScreen->GetTextSize("not on the others.");
pScreen->WriteText( width/2 - tx.x/2,height/2 - tx.y/2+40, "not on the others.");
//ESC to exit at any time
IF( GetKeyState(0x1B)) exit_game = TRUE;

//target 75 frames per second for ball movement.
mElapsed = timeGetTime() - mTimer;
mTimer = timeGetTime();
mAdjust = mElapsed / 13.3333;
fps = pScreen->Flip(1);
} UNTIL exit_game = TRUE;
//clean up and end
pScreen->CloseScreen();
delete pw1;delete pw2;delete pScreen;
return 0;
}

SUB Setup
{
//Our initial settings
width = 440;
height = 480;
border_size = 7;
num_lines = 10;
topspace = 40 + border_size;
bottomspace = border_size;
border_color = RGB(192,192,255);
fps = 0;
exit_game = FALSE;
}

SUB DrawBorder()
{
C2Dsurface *back = pScreen->GetBack();
back->DrawFilledRect( 0,0,width,border_size,border_color);// top
back->DrawFilledRect( 0,height-border_size,width,border_size,border_color);// bottom
back->DrawFilledRect( 0,0,border_size,height,border_color);// left
back->DrawFilledRect( width-border_size,0,border_size,height,border_color);// right
RETURN;
}

SUB ShowStatus()
{
pScreen->WriteText( border_size+10,border_size+10,"This is the 2D screen area");
pScreen->WriteText( border_size+10,45,"FPS: "+str$(fps));
RETURN;
}

SUB w1Txt()
{
w1g = Rand(255);w1b = Rand(255);
pw1->setwindowcolor(rgb(100,w1g,w1b));
pw1->rEdit.SetDefaultColor(w1g);// ? not working <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pw1->rEdit.SetColor(0,w1g);// ? not working <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pw1->DrawMode(TRANSPARENT);
pw1->WriteText(5,20,"scrollable text/input");
pw1->WriteText(5,50,"rgb: r: 100ÂÃ,  ÂÃ,  g: "+NumToStr(w1g)+"ÂÃ,  ÂÃ,  b: "+NumToStr(w1b));
for(x=0;x<100;x++)
{
pw1->rEdit.SetText("test line # "+NumToStr(x));// ? not working <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
}
SUB w2Txt()
{
w2g = Rand(255);w2b = Rand(255);
pw2->setwindowcolor(rgb(100,w2g,w2b));
pw2->DrawMode(TRANSPARENT);
pw2->WriteText(5,20,"text screen");
pw2->WriteText(5,50,"rgb: r: 100ÂÃ,  ÂÃ,  g: "+NumToStr(w2g)+"ÂÃ,  ÂÃ,  b: "+NumToStr(w2b));
}

//MyWindow Implementation
MyWindow::MyWindow(){ }
MyWindow::_MyWindow(){ }
MyWindow::OnClose(),int { Destroy(); return 0; }
MyWindow::OnControl(int nID, int nNotifyCode, unsigned int hControl),int
{
select nID
{
case 1: //The OK button
if(nNotifyCode = 0)
w1Txt();
//MessageBox(this,"OK Pressed","Info");
case 2: //The Exit button
if(nNotifyCode = 0)
w2Txt();
case 3: //The Exit button
if(nNotifyCode = 0)
w1Txt();w2Txt();
case 4: //The Exit button
if(nNotifyCode = 0)
w2Txt();
}
return 0;
}

MyWindow::OnCreate(),int
{
AddControl(CTBUTTON,"This Color",0,270,80,20,0x5000000B,0x0,1);
AddControl(CTBUTTON,"Color Below",80,270,90,20,0x5000000B,0x0,2);
AddControl(CTBUTTON,"Bth",170,270,30,20,0x5000000B,0x0,3);
AddControl(CTRICHEDIT,"",10,135,180,125,0x50B000C4,0x200,4);
return 0;
}


Ionic Wind Support Team

Thats because you have two rich edit controls.  You have a member variable CRichEdit rEdit; which isn't doing anything for you since you never create it.  And your adding one with AddControl, which is the one your seeing on screen.

Study up a bit more on controls, see weatherman.src, etc.   If you want to access the rich edit control your adding with AddControl then use the GetControl method.  Or use the member variable and call the Create.  Just don't use both ;)  I would just save a pointer to the control created with AddControl.

...in the MyWindow definition
CRichEdit *m_prEdit;

...in OnCreate
AddControl(CTRICHEDIT,"",10,135,180,125,0x50B000C4,0x200,4);
m_prEdit = GetControl(4);

Then you can access it like so:

pw1->m_prEdit->SetDefaultColor(w1g);







Ionic Wind Support Team

kryton9

August 06, 2006, 03:17:59 AM #20 Last Edit: August 06, 2006, 04:42:15 AM by kryton9
Wow, I am glad I asked as I spent a good amount of time trying to figure out what was wrong and did searches for settext etc. After reading your answer, I would never have guessed that I had created 2 of them. Thanks can't wait to try it out :)

edit: Ok back a little later. Got it sort of going. I still couldn't change the background of the rich edit control. I tried setcolor as you used in weatherman, but no luck with the rich edit.
Using setdefaultcolor is probably better in terms of making it easy to read, but it would be nice
to know how change the background color. Really sleepy, need to get to bed.

// Windows Program
// Fifth Version
// Based off of the breakout example
// for the 2d screen stuff

#typedef UINT unsigned int;
DECLARE IMPORT,timeGetTime(),UINT;
class MyWindow : CWindow
{
declare MyWindow();
declare _MyWindow();
declare virtual OnClose(),int;
declare virtual OnControl(int nID, int nNotifyCode, unsigned int hControl),int;
declare virtual OnCreate(),int;
CRichEdit *prEdit;
}

//Global variables
int width;
int height;
int border_size;
int num_lines;
int topspace;
int bottomspace;
unsigned int border_color;
int fps;
int exit_game;
int mElapsed,mTimer,lastY;
double mAdjust;
MyWindow *pw1;
CWindow *pw2;
C2DScreen *pScreen;

global sub main()
{
Setup();
//Scroll text screen
pw1=new(MyWindow,1);
pw1->Create(width+4,0,200,height*.6,AWS_AUTODRAW | AWS_VISIBLE | AWS_POPUP ,0,"",0);
w1Txt();
//text screen
pw2=new(CWindow,1);
pw2->Create(width+4,height*.6,200,height*.4,AWS_AUTODRAW | AWS_VISIBLE | AWS_POPUP ,0,"",0);
w2Txt();
//2D screen create
pScreen = new(C2DScreen,1);
pScreen->CreateWindowed(0,0,width+4,height,AWS_VISIBLE|AWS_POPUP,0,"2D Multi Screen Test - ESC to exit",0);
pScreen->SetStretchedFlip(FALSE);
sz = pScreen->GetClientRect();
width = sz.right;
height = sz.bottom;
pScreen->SetFocus();
C2DSurface *back = pScreen->GetBack();

//turn off the cursor
pScreen->SetCursor(CS_CUSTOM,0);// if you want the cursor in the 2d screen, comment out this line
//Set our font and text colors
pScreen->SetFont("Ariel",12,600);
pScreen->FrontPen(RGB(192,192,255));
pScreen->DrawMode(TRANSPARENT);

mTimer = timeGetTime();
point tx;
DO
{
back->Fill(0);
ShowStatus();
DrawBorder();

//show game over graphics
tx = pScreen->GetTextSize("The mouse is hidden");
pScreen->WriteText( width/2 - tx.x/2,height/2 - tx.y/2, "The mouse is hidden");
tx = pScreen->GetTextSize("on this screen, but");
pScreen->WriteText( width/2 - tx.x/2,height/2 - tx.y/2+20, "on this screen, but");
tx = pScreen->GetTextSize("not on the others.");
pScreen->WriteText( width/2 - tx.x/2,height/2 - tx.y/2+40, "not on the others.");
//ESC to exit at any time
IF( GetKeyState(0x1B)) exit_game = TRUE;

//target 75 frames per second for ball movement.
mElapsed = timeGetTime() - mTimer;
mTimer = timeGetTime();
mAdjust = mElapsed / 13.3333;
fps = pScreen->Flip(1);
} UNTIL exit_game = TRUE;
//clean up and end
pScreen->CloseScreen();
delete pw1;delete pw2;delete pScreen;
return 0;
}

SUB Setup
{
//Our initial settings
width = 440;
height = 480;
border_size = 7;
num_lines = 10;
topspace = 40 + border_size;
bottomspace = border_size;
border_color = RGB(192,192,255);
fps = 0;
exit_game = FALSE;
}

SUB DrawBorder()
{
C2Dsurface *back = pScreen->GetBack();
back->DrawFilledRect( 0,0,width,border_size,border_color);// top
back->DrawFilledRect( 0,height-border_size,width,border_size,border_color);// bottom
back->DrawFilledRect( 0,0,border_size,height,border_color);// left
back->DrawFilledRect( width-border_size,0,border_size,height,border_color);// right
RETURN;
}

SUB ShowStatus()
{
pScreen->WriteText( border_size+10,border_size+10,"This is the 2D screen area");
pScreen->WriteText( border_size+10,45,"FPS: "+str$(fps));
RETURN;
}

SUB w1Txt()
{
string s$;
w1g = Rand(255);w1b = Rand(255);
pw1->setwindowcolor(rgb(100,w1g,w1b));
pw1->prEdit->SetDefaultColor(rgb(100,w1g,w1b));
pw1->prEdit->SetMargins(10,10);
pw1->DrawMode(TRANSPARENT);
pw1->WriteText(5,20,"scrollable text/input");
pw1->WriteText(5,50,"rgb: r: 100    g: "+NumToStr(w1g)+"    b: "+NumToStr(w1b));
for(x=0;x<11;x++)
{
s$ = s$+"test line # "+NumToStr(x)+Chr$(13);
}
pw1->prEdit->SetText(s$);
}
SUB w2Txt()
{
w2g = Rand(255);w2b = Rand(255);
pw2->setwindowcolor(rgb(100,w2g,w2b));
pw2->DrawMode(TRANSPARENT);
pw2->WriteText(5,20,"text screen");
pw2->WriteText(5,50,"rgb: r: 100    g: "+NumToStr(w2g)+"    b: "+NumToStr(w2b));
}

//MyWindow Implementation
MyWindow::MyWindow(){ }
MyWindow::_MyWindow(){ }
MyWindow::OnClose(),int { Destroy(); return 0; }
MyWindow::OnControl(int nID, int nNotifyCode, unsigned int hControl),int
{
select nID
{
case 1: //The OK button
if(nNotifyCode = 0)
w1Txt();
//MessageBox(this,"OK Pressed","Info");
case 2: //The Exit button
if(nNotifyCode = 0)
w2Txt();
case 3: //The Exit button
if(nNotifyCode = 0)
w1Txt();w2Txt();
case 4: //The Exit button
if(nNotifyCode = 0)
w2Txt();
}
return 0;
}

MyWindow::OnCreate(),int
{
AddControl(CTBUTTON,"This Color",0,270,80,20,0x5000000B,0x0,1);
AddControl(CTBUTTON,"Color Below",80,270,90,20,0x5000000B,0x0,2);
AddControl(CTBUTTON,"Bth",170,270,30,20,0x5000000B,0x0,3);
AddControl(CTRICHEDIT,"",10,135,180,125,0x50B000C4,0x200,4);
prEdit = GetControl(4);
return 0;
}

Ionic Wind Support Team

Rich Edit controls don't follow the same coloring scheme as other windows controls.  Instead it has its own message you need to send it.

#define EM_SETBKGNDCOLOR 0x400 + 67
DECLARE IMPORT,SendMessageA(uint hwnd,uint uMsg,uint wParam,uint lParam),uint;
...
SendMessageA(m_prEdit->m_hWnd,EM_SETBKGNDCOLOR,0, color);

The default background color follows the system color set in display properties.  If you wish to reset the control to again use the window background color then it is:

SendMessageA(m_prEdit->m_hWnd,EM_SETBKGNDCOLOR, true , 0);
Ionic Wind Support Team

kryton9

Again thanks, never in a million years would I have ever figured that one out either.
I still don't understand it, but will put it in, maybe then I can back trace and figure it out.

Thanks

Ionic Wind Support Team

Microsoft probably explains it better. 

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devnotes/winprog/wm_ctlcolor_.asp

So in early windows there was one unified way to set a controls color.  Then starting with Windows 95 there were individual messages depedning on the control type.  These messages are sent to the parent window.  Aurora handles processing the individual messages by reflecting them back to the control so the control handles it's own colors.

However the common controls such as RichEdit, ListView, TrackBar, etc. don't follow the old ways and instead have their own messages that you send to the control.  No real standard way of doing it.  Now I could have the CRichEdit class send the message when you use SetColor.  But then have to have a way to reset it back to using the control panel settings.  So it just got left out for the moment.

ListView is more problematic since there really isn't a background color.  See the example 'listview2.src' to see what I mean.

Paul.

Ionic Wind Support Team

kryton9

Paul, you are amazing how you are doing what you are doing. I was researching all the languages out there and the latest directx and the fact that you are pulling this off is just mind blowing.
You look at the microsoft site and read up on their .net versions and non .net versions and how some directx 9 will work with some versions and not others. What microsoft will be supporting and not, it is a mess.

The same with other languages, I know at game creators, they dropped the the version of microsoft c++ they had targeted their sdk to another version after the users on the forums I guess cried out.

You look at websites that have tutorials on directx programming and it is a mess, you need almost the exact version that the user is developing in setup the same way to make them run. So the whole idea of c and c++ being standard seem really messed up.

Aurora really is the only thing out there other than buckling down and going with the latest microsoft versions. They should just make you head of development at Microsoft and maybe the programming world would become sane again.