PDA

View Full Version : CL_GUIComponent not drawing properly when CL_GraphicContext is moved



Trollger
08-11-2012, 12:10 AM
I'm on the early steps of creating a top down RTS game and I am trying to make it so that when the mouse hits the edges of the screen the graphics context moves. That part of the code works just fine, however when I move it the GUI does not follow.

I can click on where the one button should be and I get the classic "Hello World" Text in the console but the button itself is being draw where is started, in other words the button can be clicked on where is should be but the part that can be seen is not moving.

I'll explain the code that is relevant

This is the GUI class I made, it inherits from the CL_GUIComponenet class and will be used to draw all of the GUI. obviously this is the cpp file. I didn't include the header



GuiApp::GuiApp(CL_GUIManager *manager, CL_GUITopLevelDescription description) : CL_GUIComponent(manager,description) {
MyButton = new CL_PushButton(this);
MyButton->set_text("Okay!");
MyButton->set_geometry(CL_Rect(10,10,100,80));
MyButton->func_clicked().set(&on_button1_clicked, MyButton);
}


void GuiApp::on_button1_clicked(CL_PushButton *button)
{
CL_Console::write("Hello World");
}


I included that into my project



GuiApp MainGUI(&GUI,CL_GUITopLevelDescription("MyGui",CL_Size (GameResolutionWidth,GameResolutionHeight), true));


GUI is the guimanager class. The GUI was made like in the direct render examples with the CL_GUIWindowManagerTexture class
The last part that I believe is relevant is the main loop. Window manager is a CL_GUIWindowManagerTexture class



gc.clear();
gc.set_translate(CameraX,CameraY,0);
DrawEverything();

WindowManager.process();
WindowManager.draw_windows(gc);
window.flip(1);


CL_KeepAlive::process();
CL_System::sleep(10);

Griz
08-11-2012, 02:13 PM
Try reseting the translation of gc before drawing the gui.



DrawEverything();

gc.set_translate(0,0);

WindowManager.draw_windows(gc);

Trollger
08-11-2012, 05:27 PM
worked wonderfully, thanks.