BetaGUI : BetaGUI 2.5 update - Style system added.

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
Post Reply
Banthia
Gnoblar
Posts: 3
Joined: Thu Jun 01, 2006 6:49 pm

Post by Banthia »

Cool little piece of code, thank you, betajaen. I slipped BetaGUI into an existing overlay abstraction framework that manages simple gui views and state, just a few wrinkles. I did remove the global "using namespace" statements, replacing with the fully qualified Ogre:: and std:: throughout your file, as there were a few ambiguities with other namespaces. Obfuscation, hehe this extra bit didn't hurt :wink:
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: San Francisco
x 13
Contact:

Post by nikki »

betajaen wrote:I've added some changes to BetaGUI onto the non-compressed version which handles multiple BetaGUI's at the same time (so you can have different levels of Z-Ordering), another bug fix, and the biggest change the ability to detect mouse overs and mouse outs on buttons.
Does the uncompressed version you posted earlier have these changes?

I get this error (always for number 11):-

Code: Select all

Error #: 6
Function: OverlayManager::createOverlayElement
Description: OverlayElement with name BetaGUI.w11 already exists.. 
File: c:\ogre\ogrenew\ogremain\src\ogreoverlaymanager.cpp
Line: 549
Stack unwinding: <<beginning of stack>>
Seems like the window number (the '.w11' part) is not getting incremented properly. Any ideas?

I am (almost) sure that it crashes only at the number 11 (I have tried not creating some windows, creating extra windows etc.). It isn't that it happens to the same window, just the window called 'BetaGUI.w11'.
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Post by betajaen »

Hmm.

I think I may of fixed that problem already. Try it with this uncompressed unreleased version and see how it goes:

http://get.nxogre.org/betagui/
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: San Francisco
x 13
Contact:

Post by nikki »

Cool, new BetaGUI!
/* tries it out */
Boom! BetaGUI.w11 already exists.

I have a little question about the uchar parameter to the BetaGUIListener:-
0 means mouseover and 1 means clicked, right, but what's 3?
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Post by betajaen »

Mouse has moved out, for some reason I set it as 3, it should be 2.

Fixed your problem, it was do with the StaticText inhering the windows name and adding a number to it. Which is fine, but there should be a ".st" between. ;)

Download via the link above.
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: San Francisco
x 13
Contact:

Post by nikki »

I still get the error (a bit different though):-

Code: Select all

Error #: 6
Function: OverlayManager::createOverlayElement
Description: OverlayElement with name GUIBase.w11 already exists.. 
File: c:\ogre\ogrenew\ogremain\src\ogreoverlaymanager.cpp
Line: 549
Stack unwinding: <<beginning of stack>>
GUIBase is the baseOverlayName that I passed to the GUI.
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Post by betajaen »

Odd. Really odd, and I can't see why is it doing it.

Any chance for some of your setup gui code?
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: San Francisco
x 13
Contact:

Post by nikki »

Yes! I fixed it, but I'm pretty sure I'll be encountering this again. :)
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Post by betajaen »

nikki wrote:Yes! I fixed it, but I'm pretty sure I'll be encountering this again. :)
Enlighten me, what was the fix or problem?
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: San Francisco
x 13
Contact:

Post by nikki »

betajaen wrote:
nikki wrote:Yes! I fixed it blah blah ...
Enlighten me, what was the fix or problem?
In my main menu screen, an arrow is drawn beside the button when the mouse is over it. This was done by creating a window.

I was thinking that when the uint passed to the callback is zero it means the mouse entered the button (an event), not that it means the mouse is inside the button (called every frame the mouse is in). I created the arrow window whenever this callback function was called with this particular parameter.

So, more than a 1000 windows were created in no time. :)

Later, I fixed it so that a window is created only when the mouse enters the button.
grizzley90
Gnome
Posts: 318
Joined: Wed Jan 18, 2006 7:22 pm
Location: Montreal, Canada

Post by grizzley90 »

Is it possible to have a version with full variable names and comments because im trying to translate it to another language and i can't understand what some of the code does and why its there, its really not understandable especially with the really really short variable names. I know its not meant to be readable but still i would like to use it. I dont know if this is possible but i hope it will be.
zzgame
Gnoblar
Posts: 19
Joined: Tue May 16, 2006 8:38 am
Location: bj, china

Post by zzgame »

but I donot Know how to use this code in the wiki:

mGUI->injectKey(<character>, <pointer x>, <pointer y>);
mGUI->injectBackspace(<pointer x>, <pointer y>); //
mGUI->injectMouse(<pointer x>, <pointer y>, true); // Mouse key down.
mGUI->injectMouse(<pointer x>, <pointer y>, false); // Mouse key not down.

class myCallbackOrMainClass : public public BetaGUI::BetaGUIListener {
...
void onButtonPress(BetaGUI::Button *ref) {
if (ref == mDoubleIt)
cout << "The answer is:" << StringConverter::parseUnsignedInt(mAmount->getValue()) * 2 << endl;
}
...
}
who can help me thanks!
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: San Francisco
x 13
Contact:

Post by nikki »

You need to execute the key events in a OIS::KeyListener. The mouse events must be called per frame, so there is no need of a mouse listener. A FrameListener's frameStarted method will do. :)
yarock
Halfling
Posts: 42
Joined: Fri Apr 14, 2006 8:06 pm

Post by yarock »

zzgame wrote:but I donot Know how to use this code in the wiki:

mGUI->injectKey(<character>, <pointer x>, <pointer y>);
mGUI->injectBackspace(<pointer x>, <pointer y>); //
mGUI->injectMouse(<pointer x>, <pointer y>, true); // Mouse key down.
mGUI->injectMouse(<pointer x>, <pointer y>, false); // Mouse key not down.

class myCallbackOrMainClass : public public BetaGUI::BetaGUIListener {
...
void onButtonPress(BetaGUI::Button *ref) {
if (ref == mDoubleIt)
cout << "The answer is:" << StringConverter::parseUnsignedInt(mAmount->getValue()) * 2 << endl;
}
...
}
add me to that question.. can someone give us a simple exit button example??? please some help here....
User avatar
lonewolff
Ogre Magi
Posts: 1207
Joined: Wed Dec 28, 2005 12:58 am
x 6

Post by lonewolff »

Yeah, some sample code would be great.

I am trying to implement something basic into 'Basic Tutorial 1' from the wiki.
And I get errors like the following;
mGUI: undeclared identifier //what should it be declared as?
left of '->createWindow' must point to a class/struct/union //what the?
typecast: cannot convert from 'TutorialApplication *const' to 'BetaGUI::callback' //again what the?
Tutorials for us noobs would be greatly appreciated.
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Post by betajaen »

Alright, this is what the NxOgre tutorials use.

It's written for OIS/Eihort but it's easily adaptable to the Dagon Input system:


Basic setup Note the: "public BetaGUI::BetaGUIListener"

Code: Select all

class SimpleTutorialEihort : public FrameListener, public OIS::KeyListener, public BetaGUI::BetaGUIListener {

BetaGUI::GUI*	mGUI;
BetaGUI::Window* mGUI_ExitWindow;
BetaGUI::Button* mGUI_ExitButton;
uint mouseX, mouseY;

bool mShutdown;


Create the GUI, Window and Mouse pointer

Code: Select all

void createGUI() {

mShutdown = false;
mouseX = 0;
mouseY = 0;

// Create the GUI
mGUI = new BetaGUI::GUI("nxogrefont",16);

// Create a window
mGUI_ExitWindow = GUI->createWindow(100,100,200,200), "Wee", BetaGUI::RESIZE_AND_MOVE);
mGUI_ExitButton =  mGUI_ExitWindow->createButton(Vector4(4         ,28,100,22), "bgui.button", "Quit", BetaGUI::Callback(this));

// Create the mouse pointer
mPointer = mGUI->createMousePointer(Vector2(32,32), "bgui.pointer");

// OIS setup code goes here.

}

Handle callbacks

Code: Select all

void onButtonPress(BetaGUI::Button *ref) {		
	if (ref == mGUI_ExitButton)
		mShutdown = true;
}
Injecting mouse movement

Code: Select all

bool frameStarted(const FrameEvent& evt) {
			
	if (mShutdown)
		return false;

	const MouseState &ms = mMouse->getMouseState();
	
	// Mouse injection must be absolute position than relative.
	mouseX+= ms.relX;
	mouseY+= ms.relY;

	if (ms.buttons == 1)
		mGUI->injectMouse(mouseX, mouseY, true);  // LMB is down.
	else
		mGUI->injectMouse(mouseX, mouseY, false); // LMB is not down.

	return true;
}
Injecting a keypress

Code: Select all

bool keyPressed( const KeyEvent &arg ) {
			
	// Injecting a backspace
	if (arg.text == 8) {
		mGUI->injectBackspace(mPointer->getLeft(), mPointer->getTop());
		return true;
	}

	// Ignore non-printable or "unsafe" characters.
	if (arg.text < 32 || arg.text > 126)
		return true;

	// Convert keycode into a (1 char) string.
	string k;
	k = static_cast<char>(arg.text);
	mGUI->injectKey(k, mouseX, mouseY);
	return true;
}

};
That's it!
zzgame
Gnoblar
Posts: 19
Joined: Tue May 16, 2006 8:38 am
Location: bj, china

Post by zzgame »

thanks betajaen ! it is very well to explain how to use the betagui, I will try it :)
yarock
Halfling
Posts: 42
Joined: Fri Apr 14, 2006 8:06 pm

thnaks ..

Post by yarock »

as you see you are ussing in the learning code ,

Code: Select all

const MouseState &ms = mMouse->getMouseState();
without define a mMouse, i make a mMouse a

Code: Select all

InputReader *mMouse;
, only for the getmousesate(), but can some one explain me what i do need to put in the params for the getmousesate()!!?????, in the example, was nothing, but... not working 4 me ( dagon user) please i some help
zzgame
Gnoblar
Posts: 19
Joined: Tue May 16, 2006 8:38 am
Location: bj, china

Post by zzgame »

this use OIS input lib :public OIS::KeyListener,not ogre input
yarock
Halfling
Posts: 42
Joined: Fri Apr 14, 2006 8:06 pm

Post by yarock »

sorry the noob question, but what are the equivalents values for thats variables( mMouse, and OIS::FrameListener), y tried wthis ogre inputreader, ogre key and mouse Listeners,,,.... please help



im with Dagon....
Last edited by yarock on Fri Dec 01, 2006 1:10 am, edited 1 time in total.
zzgame
Gnoblar
Posts: 19
Joined: Tue May 16, 2006 8:38 am
Location: bj, china

Post by zzgame »

it is a better way to understand betagui to see the ogre cegui demo, two are simliar,if you want to do it with ogre input,i will put my code when i go home,but my code have a bug cannot input text :(
yarock
Halfling
Posts: 42
Joined: Fri Apr 14, 2006 8:06 pm

Post by yarock »

your using BetaGui??, i be so thanksfull if you or some body explain or send a example or compiled tutorial, thanks,


.. and dont matter about input text, i just need a panel with exit button, start button, just that



right now, i can show a pointer, and a gui( w/ betagui), but i dont know the event part, and mouse movement,
zzgame
Gnoblar
Posts: 19
Joined: Tue May 16, 2006 8:38 am
Location: bj, china

Post by zzgame »

my code here:
GuiListener.h
#pragma once
#include "BetaGUI.h"
#include "ogre.h"
#include "ExampleFrameListener.h"
#include <OgreEventQueue.h>
class CGuiListener :public ExampleFrameListener, public Ogre::MouseMotionListener, public Ogre::MouseListener
{
public:
CGuiListener(RenderWindow* win, Ogre::Camera* cam,BetaGUI::GUI* m_GUI) : ExampleFrameListener(win,cam)
{
mGUI = m_GUI;
///////
mInputDevice2 = mInputDevice;

mEventProcessor = new Ogre::EventProcessor();
mEventProcessor->initialise(win);
mEventProcessor->startProcessingEvents();
mEventProcessor->addKeyListener(this);
mEventProcessor->addMouseMotionListener(this);
mEventProcessor->addMouseListener(this);
mInputDevice = mEventProcessor->getInputReader();

}

~CGuiListener()
{
mEventProcessor->stopProcessingEvents();
mEventProcessor->removeKeyListener(this);
mEventProcessor->removeMouseMotionListener(this);
mEventProcessor->removeMouseListener(this);
delete mEventProcessor;

mInputDevice = mInputDevice2;
}


virtual void mouseMoved (MouseEvent *e)
{
int a = e->getRelX();
int b = e->getRelY();
int c = mWindow->getWidth();
int d = mWindow->getHeight();
mGUI->injectMouse(e->getX()* mWindow->getWidth(),e->getY() * mWindow->getHeight(),false);
e->consume();
}


virtual void mouseDragged (MouseEvent *e)
{
mouseMoved(e);
}


virtual void keyPressed (KeyEvent *e)
{

Ogre::String key;
char a[2];
a[0] = e->getKeyChar();
a[1] = '\0';
key = a;
mGUI->injectKey(key,5,51);

e->consume();
}


virtual void keyReleased (KeyEvent *e)
{
}

virtual void mousePressed (MouseEvent *e)
{
mGUI->injectMouse(e->getX()* mWindow->getWidth(),e->getY() * mWindow->getHeight(),true);
e->consume();
}


virtual void mouseReleased (MouseEvent *e)
{
mGUI->injectMouse(e->getX()* mWindow->getWidth(),e->getY() * mWindow->getHeight(),false);
e->consume();
}


virtual void keyClicked (KeyEvent *e) {}
virtual void mouseClicked (MouseEvent *e) {}
virtual void mouseEntered (MouseEvent *e) {}
virtual void mouseExited (MouseEvent *e) {}


bool frameStarted(const FrameEvent& evt);


protected:
Ogre::EventProcessor* mEventProcessor;
Ogre::InputReader* mInputDevice2;
BetaGUI::GUI* mGUI;
};
zzgame
Gnoblar
Posts: 19
Joined: Tue May 16, 2006 8:38 am
Location: bj, china

Post by zzgame »

GuiListener.cpp
#include ".\guilistener.h"

bool CGuiListener::frameStarted( const FrameEvent &evt )
{

return true;

}
yarock
Halfling
Posts: 42
Joined: Fri Apr 14, 2006 8:06 pm

Post by yarock »

that a big piece of code, but a question, why is this code i snot the same of betajens code of topics up???
Post Reply