Navi

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
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

In Navi.cpp's Navi::hide, you do not set isVisible to false. I added this as the last line
whoops, I had indeed forgotten to set 'isVisible' to false when using a non-fading hide. (When you use a fading hide, 'isVisible' is set to false at the end of the duration in Navi::update) Thanks for the tip!
2) In NaviManager.cpp's Navi::getNavisAtPoint, I added an additional check.
That is not needed because Navi::isPointOverMe will always return false if a Navi is not visible (isVisible is false).
User avatar
Noman
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 714
Joined: Mon Jan 31, 2005 7:21 pm
Location: Israel
x 2
Contact:

Post by Noman »

Ok. That works :)

Anyway, another day, another issue, another (i think) solution.

In my main navi (team creation) i have a button that switches to another navi (class selection). I push it, go to the select class navi, select a class and return to the main window. Its all good. However, when i push an input button on the main navi after doing that, Navi thinks that another "SelectClass" NaviData message has been sent, and takes me back to the class selection.

What happens (I think) is that clicking the input button triggers a status change (because you might be submitting something) and then reverts back to the previous status, causing the SelectClass message to be resent.

What i did to solve this, is in Navi.js's send() function, i ended it like this :

Code: Select all

...
window.status = ""
return this;


This causes the status to be reset, so the same navidata does not get sent twice. It solved my problem and I have experienced no side effects from this change as of yet.
User avatar
Noman
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 714
Joined: Mon Jan 31, 2005 7:21 pm
Location: Israel
x 2
Contact:

Post by Noman »

My second milestone in the game i am working on (hobbyist, not pro) was to have a fully functional team editor working, in order to choose a gui library for the game. I decided to go along with navi and am quite happy with the results.

Here it is :

This is how it looks in the beginning
Image
This is how it looks after creating a few characters
Image
This is the screen that shows up when you click the blue question mark next to the class name.
Image

Still looks HTMLish, but I am not through with the design part. Colors and fonts will probably be repicked, more images of the avatars of the classes will be added etc. But it is functional. (And i am a programmer so this is programmer art :)
And i am proud to say that the c++ code that works with the navi (creation, handling events, supplying the numbers from the logic side of the game, extracting the data from the Navi and creating a "Logic" team) is less than 200 lines of code.

I'm very happy with the results so far. Thanks for the great library. Hopefully the project will open up its own thread in the showcase forum in the not too distant future.

If anyone has any ideas on how i couldve done things differently, I would love to read comments, as i dont have much experience with BLOCKED (or GUI design for that matter, especially not for games).

I'll probably annoy you a bit less in the near future, as now that im finished with this proof of concept, I'm starting to work on the main state of the game, so it will be much less Navi-centric. Thanks for all the support!
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

Noman wrote:Ok. That works :)

Anyway, another day, another issue, another (i think) solution.

In my main navi (team creation) i have a button that switches to another navi (class selection). I push it, go to the select class navi, select a class and return to the main window. Its all good. However, when i push an input button on the main navi after doing that, Navi thinks that another "SelectClass" NaviData message has been sent, and takes me back to the class selection.

What happens (I think) is that clicking the input button triggers a status change (because you might be submitting something) and then reverts back to the previous status, causing the SelectClass message to be resent.

What i did to solve this, is in Navi.js's send() function, i ended it like this :

Code: Select all

...
window.status = ""
return this;


This causes the status to be reset, so the same navidata does not get sent twice. It solved my problem and I have experienced no side effects from this change as of yet.
I don't recommend using an <input type="submit" /> in your HTML (at least not without overriding the form action). Doing so will cause an undesired refresh of the page.

You should instead be using an <input type="button" />. For example:

Code: Select all

<form>
<input type="button" value="Increase Number" onclick="new NaviData('increaseNum').send()" />
<br/>
<input type="button" value="Exit Application" onclick="new NaviData('exit').send()" />
</form>
I've tried to reproduce your problem and have not succeeded however I will add the status reset to Navi.js, just to be on the safe side.
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

Noman wrote:My second milestone in the game i am working on (hobbyist, not pro) was to have a fully functional team editor working, in order to choose a gui library for the game. I decided to go along with navi and am quite happy with the results.

Here it is :

This is how it looks in the beginning
Image
This is how it looks after creating a few characters
Image
This is the screen that shows up when you click the blue question mark next to the class name.
Image

Still looks HTMLish, but I am not through with the design part. Colors and fonts will probably be repicked, more images of the avatars of the classes will be added etc. But it is functional. (And i am a programmer so this is programmer art :)
And i am proud to say that the c++ code that works with the navi (creation, handling events, supplying the numbers from the logic side of the game, extracting the data from the Navi and creating a "Logic" team) is less than 200 lines of code.

I'm very happy with the results so far. Thanks for the great library. Hopefully the project will open up its own thread in the showcase forum in the not too distant future.

If anyone has any ideas on how i couldve done things differently, I would love to read comments, as i dont have much experience with BLOCKED (or GUI design for that matter, especially not for games).

I'll probably annoy you a bit less in the near future, as now that im finished with this proof of concept, I'm starting to work on the main state of the game, so it will be much less Navi-centric. Thanks for all the support!
I love it! Looks really great already (for a programmer :P). If you need any tips/HTML/design help, I'll gladly oblige.

Good luck with your project, I hope you will learn a lot. Can't wait to see what it turns into!
User avatar
Noman
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 714
Joined: Mon Jan 31, 2005 7:21 pm
Location: Israel
x 2
Contact:

Post by Noman »

ajs15822 wrote:
Noman wrote:Ok. That works :)

Anyway, another day, another issue, another (i think) solution.

In my main navi (team creation) i have a button that switches to another navi (class selection). I push it, go to the select class navi, select a class and return to the main window. Its all good. However, when i push an input button on the main navi after doing that, Navi thinks that another "SelectClass" NaviData message has been sent, and takes me back to the class selection.

What happens (I think) is that clicking the input button triggers a status change (because you might be submitting something) and then reverts back to the previous status, causing the SelectClass message to be resent.

What i did to solve this, is in Navi.js's send() function, i ended it like this :

Code: Select all

...
window.status = ""
return this;


This causes the status to be reset, so the same navidata does not get sent twice. It solved my problem and I have experienced no side effects from this change as of yet.
I don't recommend using an <input type="submit" /> in your HTML (at least not without overriding the form action). Doing so will cause an undesired refresh of the page.

You should instead be using an <input type="button" />. For example:

Code: Select all

<form>
<input type="button" value="Increase Number" onclick="new NaviData('increaseNum').send()" />
<br/>
<input type="button" value="Exit Application" onclick="new NaviData('exit').send()" />
</form>
I've tried to reproduce your problem and have not succeeded however I will add the status reset to Navi.js, just to be on the safe side.
I didn't use input type=submit, i used input type=image (Now that i think about it, i dont even need it to be an input box after my latest changes, i can use a regular image). Try having something similar to the two buttons that you put in your example, but have one of them not send a NaviData (have it do some random js or whatever). If you click it after you click the one that does send the navidata, the navidata will get resent.
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

Noman wrote:I didn't use input type=submit, i used input type=image (Now that i think about it, i dont even need it to be an input box after my latest changes, i can use a regular image). Try having something similar to the two buttons that you put in your example, but have one of them not send a NaviData (have it do some random js or whatever). If you click it after you click the one that does send the navidata, the navidata will get resent.
Aha! <input type="image" /> does the same behavior as <input type="submit" />. That's why :D.

But yeah, I really recommend instead doing something like this for a custom button:

Code: Select all

<div style="width: 100px; height: 20px; background-image: url('button_bg.jpg');" onclick="new NaviData('btn_clicked').send()">Click me!</div>
Nudel
Halfling
Posts: 79
Joined: Thu Mar 23, 2006 4:14 pm
Location: Vienna

Post by Nudel »

Something that allways bothered me was the lack of tree selections in most gui systems. But with navi, css, html and javascript it was incredibly easy to create one. :D I've never spend much attention to html, javascript and css but now it's fun to use them.

http://img134.imageshack.us/img134/1483 ... n01jz7.jpg
http://img134.imageshack.us/img134/8457 ... n02pu6.jpg
User avatar
Virion
Halfling
Posts: 85
Joined: Mon Jul 24, 2006 11:06 am
Location: Malaysia
x 2

Post by Virion »

@ajs15822 I like your cursor. :lol:
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

Nudel wrote:Something that allways bothered me was the lack of tree selections in most gui systems. But with navi, css, html and javascript it was incredibly easy to create one. :D I've never spend much attention to html, javascript and css but now it's fun to use them.

http://img134.imageshack.us/img134/1483 ... n01jz7.jpg
http://img134.imageshack.us/img134/8457 ... n02pu6.jpg
Yup, I've been slacking on my web skills the past few months until I found a reason to sharpen them again (Navi). Learning CSS/JS/SVG is just way more exciting when you know that it could help you make a better Game GUI.

Navi's main advantage above all other GUI solutions is that you are almost unlimited in design and functionality. You are not given a predefined list of 'GUI Widgets' nor are you given predefined 'Look and Feel's. For the novice user, they may find Navi too "hard" because it does not make these design choices for them, they will most definitely move on to a more accommodating solution. I personally view every Navi as an open canvas on which I can design and implement almost anything I want to. The tools are there, there's an immense amount of resources already available online, the only problem is coming up with a vision. ;)

Your trees look really smooth, nice work!

Virion wrote:@ajs15822 I like your cursor. :lol:
heh, thanks ^^
User avatar
Noman
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 714
Joined: Mon Jan 31, 2005 7:21 pm
Location: Israel
x 2
Contact:

Post by Noman »

I think navi's main advantage over other current systems, is that because it uses an external gui "library" and just renders it to ogre, we get instant dev tools to go along with it. QuickGUI, Cegui etc are all tools that can make excellent looking gui's with some advantages over navi (for example, i dont know how easy it is to do a button that has different states for regular, hover, push, active and maybe even combinations like active+push), but as long as the tools to properly design guis (which include things like imagesets and schemes in the case of the others), its a lot harder and less efficient (only my opinion of course) to create guis with them, thus bringing the developer further from their maximum potential and eventually creating guis that don't look as good as those that can be created with navi, despite its potentially inferior potential.

Yes, some guis have design tools, but they are all lacking. Navi elegantly hops over that hurdle.

Html question (didnt find an answer for this anywhere). Is there a way to inline fonts to a page? I want to include a custom font, but i dont want the game's installer (or whatever) to install fonts on the computer. Most other gui libraries do this by having a custom font rendering engine. How do llmozlib/gecko work?
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

Noman wrote:QuickGUI, Cegui etc are all tools that can make excellent looking gui's with some advantages over navi (for example, i dont know how easy it is to do a button that has different states for regular, hover, push, active and maybe even combinations like active+push)
Oh come on, that's too easy with MooTools :D

Code: Select all

<input type="button" id="myButton" value="Click me!" />
<script type="text/javascript">
	var visited = false;
	var setButtonColor = function(color){ $('myButton').setStyle('background-color', color) };
	$('myButton').addEvents({
		mouseover: setButtonColor.pass('gray'),
		mouseout: setButtonColor.pass('white'),
		mousedown: function(){ visited ? setButtonColor('blue') : setButtonColor('red') },
		mouseup: setButtonColor.pass('white'),
		click: function(){ visited ? alert('You already clicked me!') : alert("Yay, first click."); visited = true; }
	});
</script>
Noman wrote:As long as the tools to properly design guis (which include things like imagesets and schemes in the case of the others), its a lot harder and less efficient (only my opinion of course) to create guis with them, thus bringing the developer further from their maximum potential and eventually creating guis that don't look as good as those that can be created with navi, despite its potentially inferior potential.

Yes, some guis have design tools, but they are all lacking. Navi elegantly hops over that hurdle.
Right, there's a reason so many people are diving into this whole 'Web 2.0' (The Web as a Platform) nonsense. The scripting languages that power this movement are very mature and there are now a plethora of stable open-source libraries that make development a breeze. For rapid development, a solid toolset is extremely necessary.
Noman wrote:Html question (didnt find an answer for this anywhere). Is there a way to inline fonts to a page? I want to include a custom font, but i dont want the game's installer (or whatever) to install fonts on the computer. Most other gui libraries do this by having a custom font rendering engine. How do llmozlib/gecko work?
Until Gecko implements the CSS2 '@font-face' spec (it's been on the wishlist forever), you won't be able to use dynamic/local fonts without installing them to the OS.
User avatar
metaldev
Orc Shaman
Posts: 761
Joined: Thu Mar 17, 2005 11:56 pm
Location: Boston
x 15
Contact:

Post by metaldev »

First of all ajs Navi is so awesome and helpful... i am definitely no professional programmer and this is a godsend.

I would like to post a small feature request if its not too much trouble to include in the next Navi version.

to have a function for injectMouseWheel that would allow to post in there a specific Navi for example:

Code: Select all

bool NaviManager::injectMouseWheel(const std::string &naviName,  int relScroll)
and also I'd like to second the previous request to allow programmatic movability of Navi's

AJS thanks so much for Navi (and for helping me personally on my other quesions/posts). you rock!
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

metaldev wrote:First of all ajs Navi is so awesome and helpful... i am definitely no professional programmer and this is a godsend.

I would like to post a small feature request if its not too much trouble to include in the next Navi version.

to have a function for injectMouseWheel that would allow to post in there a specific Navi for example:

Code: Select all

bool NaviManager::injectMouseWheel(const std::string &naviName,  int relScroll)
Wish granted, it will be in the SVN soon.

metaldev wrote:and also I'd like to second the previous request to allow programmatic movability of Navi's
Programmatic movability of Navi's (both by relative and absolute amounts) is already implemented in the latest SVN. :wink: See 'NaviManager::moveNavi' and 'NaviManager::setPosition' for more info.

metaldev wrote:AJS thanks so much for Navi (and for helping me personally on my other quesions/posts). you rock!
You're welcome, I enjoy answering your questions.



As for current development status, Navi.js is completely revamped and at a fairly stable stage, it will be in the SVN soon for testing.

I'm refactoring (rewriting) the application-side NaviData implementation so that you can write better code. Ideally I'd like to change this:

Code: Select all

void MyApplication::handleCharCreate(const NaviData &naviData)
{
	std::string charName;
	int hairColor;

	if(naviData.get("name", charName) && naviData.get("hair", hairColor))
		charMgr.create(charName, hairColor);
}
into this:

Code: Select all

void MyApplication::handleCharCreate(const NaviData &naviData)
{
	naviData.assert("name", "hair");

	charMgr.create(naviData["name"].str(), naviData["hair"].int());
}
giantjupiter
Kobold
Posts: 31
Joined: Fri Jun 10, 2005 5:59 pm

Post by giantjupiter »

Hi,

I tried to open "http://www.drupal.org" by replacing "http://navi.agelessanime.com/chat" in the demo project attached in the latest NaviLibrary 1.3.

Although the window is limited to 512*256, I am still able to view the effect and appreciate the capability of Navi.

But I also ran into a few problems.

(1) If I click on "Chat" label in the menu bar before the page "http://www.drupal.org" is loaded, I will be given an assertion failure as below,

ASSERTION: This shouldn't happen: 'mActive', file c:/mozilla/dom/src/base/nsFocusController.cpp, line 186

(2) If I click the "Chat" label after the page is competed loaded, the page is able to be displayed correctly (although compressed in a size area). I run into a run-time failure as below, if I open "Contact" in the page (others links appear fine so far)

Run-Time Check Failure #3 - The variable 'nativeWidgetChild' is being used without being initialized.

I saw this error is posted previously, but I couldn't find the answer (maybe I missed).

(3) There are some CSS errors displayed in the console window, like

CSS Error (http://drupal.org/themes/bluebeach/print.css :84.11) Unknown property '_height'. Declaration dropped.

(4) There are some warnings displayed in the console window too. One happened frequently is

WARNING: NS_ENSURE_TRUE(NS_SUCCEEDED(rv)) failed, file c:/mozilla/intl/strres/stc/nsStringBundle.cpp, line 273


and also

WARNING: NS_ENSURE_TRUE(NS_SUCCEEDED(rv)) failed, file c:/mozilla/editor/libeditor/base/nsEditor.cpp, line 1411

Thanks
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

giantjupiter wrote:Hi,

I tried to open "http://www.drupal.org" by replacing "http://navi.agelessanime.com/chat" in the demo project attached in the latest NaviLibrary 1.3.

Although the window is limited to 512*256, I am still able to view the effect and appreciate the capability of Navi.

But I also ran into a few problems.

(1) If I click on "Chat" label in the menu bar before the page "http://www.drupal.org" is loaded, I will be given an assertion failure as below,

ASSERTION: This shouldn't happen: 'mActive', file c:/mozilla/dom/src/base/nsFocusController.cpp, line 186

(2) If I click the "Chat" label after the page is competed loaded, the page is able to be displayed correctly (although compressed in a size area). I run into a run-time failure as below, if I open "Contact" in the page (others links appear fine so far)

Run-Time Check Failure #3 - The variable 'nativeWidgetChild' is being used without being initialized.

I saw this error is posted previously, but I couldn't find the answer (maybe I missed).

(3) There are some CSS errors displayed in the console window, like

CSS Error (http://drupal.org/themes/bluebeach/print.css :84.11) Unknown property '_height'. Declaration dropped.

(4) There are some warnings displayed in the console window too. One happened frequently is

WARNING: NS_ENSURE_TRUE(NS_SUCCEEDED(rv)) failed, file c:/mozilla/intl/strres/stc/nsStringBundle.cpp, line 273


and also

WARNING: NS_ENSURE_TRUE(NS_SUCCEEDED(rv)) failed, file c:/mozilla/editor/libeditor/base/nsEditor.cpp, line 1411

Thanks
You are encountering these assertions and warnings because of the nature of Gecko's Debug Mode. Gecko debug-mode asserts at the slightest invalid HTML/JS/CSS code in an effort to help developers find errors.

Most of the time it's a little too happy to help. :lol:
giantjupiter
Kobold
Posts: 31
Joined: Fri Jun 10, 2005 5:59 pm

Post by giantjupiter »

I guess there is a bug in NaviLibrary::decodeURIComponent() handling non-English character.

I experimented with the following two lines:

std::string s = NaviLibrary::encodeURIComponent(L"ä½ ");
std::wstring ws = NaviLibrary::decodeURIComponent(s);

The first line correctly converts L"ä½ " into its utf-8 string "%E4%BD%A0". But the second line fails to converts the utf-8 string back (with three exceptions).

Some digging shows the problem might be the line displayed in bold

std::wstring NaviLibrary::decodeURIComponent(std::string strToDecode)
{
std::wstring result;
std::vector<int> temp;
char buffer[2] = {0, 0};
bool repeat = false;
std::string::iterator i = strToDecode.begin();

while(i != strToDecode.end())
{
if(*i == '%')
{
if(++i == strToDecode.end()) break;
do
{
if(isHex(*i))
{
if(!repeat)
{
buffer[0] = *i;
repeat = true;
}
else
{
buffer[1] = *i;
temp.push_back(static_cast<int>(strtol(buffer, 0, 16)));
repeat = false;
}

if(++i == strToDecode.end())
break;
else if(!repeat && *i != '%')
break;
} else break;
} while(true);

if(temp.size())
{
std::vector<int>::iterator tI = temp.begin();
try {
while(utf8::distance(tI, temp.end()) > 0)
result += (wchar_t)utf8::next(tI, temp.end());
} catch(...) {}

temp.clear();
}
}
else
{
result += *i;
i++;
}
}

return result;
}

When if(isHex(*i)) is processing the second '%', it is false and the sequence jumps to the 'temp' vector processing. This is incorrect, as only the '%E4' is in the vector at the moment. For this character, "%E4%BD%A0" must be put in the vector and processed at one time.
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

giantjupiter wrote:I guess there is a bug in NaviLibrary::decodeURIComponent() handling non-English character.

I experimented with the following two lines:

std::string s = NaviLibrary::encodeURIComponent(L"ä½ ");
std::wstring ws = NaviLibrary::decodeURIComponent(s);

The first line correctly converts L"ä½ " into its utf-8 string "%E4%BD%A0". But the second line fails to converts the utf-8 string back (with three exceptions).

Some digging shows the problem might be the line displayed in bold

Code: Select all

std::wstring NaviLibrary::decodeURIComponent(std::string strToDecode)
{
	std::wstring result;
	std::vector<int> temp;
	char buffer[2] = {0, 0};
	bool repeat = false;
	std::string::iterator i = strToDecode.begin();

	while(i != strToDecode.end())
	{
		if(*i == '%')
		{
			if(++i == strToDecode.end()) break;
			do
			{
				[b]if(isHex(*i))[/b]
				{
					if(!repeat)
					{
						buffer[0] = *i;
						repeat = true;
					}
					else
					{
						buffer[1] = *i;
						temp.push_back(static_cast<int>(strtol(buffer, 0, 16)));
						repeat = false;
					}

					if(++i == strToDecode.end())
						break;
					else if(!repeat && *i != '%')
						break;
				} else break;
			} while(true);

			if(temp.size())
			{
				std::vector<int>::iterator tI = temp.begin();
				try {
					while(utf8::distance(tI, temp.end()) > 0)
						result += (wchar_t)utf8::next(tI, temp.end());
				} catch(...) {}

				temp.clear();
			}
		}
		else
		{
			result += *i;
			i++;
		}
	}

	return result;
}
When if(isHex(*i)) is processing the second '%', it is false and the sequence jumps to the 'temp' vector processing. This is incorrect, as only the '%E4' is in the vector at the moment. For this character, "%E4%BD%A0" must be put in the vector and processed at one time.
Aha, great sleuthing! You're absolutely right about this bug, I'm embarrassed to admit that I hadn't fully tested this 'decode' function with proper extended characters.

Fixed now, thanks to you. :D
Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

Post by Vectrex »

Howdy, I'm trying Navi with SVN Ogre and somethings breaking it in NaviManager::Startup
on this line
renderWindow->getCustomAttribute( "WINDOW", &tempAttr );

which looks ok to me, so any ideas?
User avatar
Glenn101
Gnoblar
Posts: 12
Joined: Sat Aug 11, 2007 11:54 am
Location: Australia, Melbourne

Post by Glenn101 »

This is great, I'll be sure to check it out sometime soon
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

Vectrex wrote:Howdy, I'm trying Navi with SVN Ogre and somethings breaking it in NaviManager::Startup
on this line
renderWindow->getCustomAttribute( "WINDOW", &tempAttr );

which looks ok to me, so any ideas?
No idea, haven't had time to fool around with SVN Ogre yet. :D
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

And, bam! New SVN commit in the trunk, we are now at Revision 14 (external v1.4).

This is a rather major commit due to the rewrite of Navi.js and NaviLibrary::NaviData.

Anyways, here is the update to the change log:

Code: Select all

API Changes since v1.3:
- In NaviManager:
-- NaviManager::bindNaviData & unbindNaviData have now been renamed bind & unbind, respectively.
-- NaviManager::bind has a new optional parameter, a string vector containing keys to validate via NaviData::ensure.
-- NaviManager::getDerivedUV has been added.
-- NaviManager::injectNaviMaterialMouseWheel has been renamed injectNaviMouseWheel because it may now be used on both regular Navis and NaviMaterials.
-- NaviManager::setNaviBackgroundColor has a new overload (takes a hex color string).
- In NaviData:
-- Completely rewritten with an std::map as a base with heavy use of a generic type, 'NaviDataValue'.
-- Primary mode of interface is via the subscript operator (naviData["myKey"]) for assignment/value retrieval.
-- NaviData::ensure may be used for validation purposes.
- In NaviUtilities:
-- Is now wrapped in a new nested namespace, NaviUtilities
-- New functions: split, splitToMap, join, joinFromMap, isPrefixed, isNumeric, numberToString, toNumber
-- New utility class, InlineVector<T> and specialization, Strings
-- NaviUtilities::replaceAll has lost a parameter, 'avoidCyclic' (no longer required due to new implementation)
- In Navi.js:
-- Completely rewritten from the ground up. Mootools v1.11 is embedded in the first section, scroll to the bottom section for the actual meat of Navi.js.
-- New combobox implementation has been included as a workaround for the current problems with native comboboxes.
-- Element.setHTMLBuffered has been included as a workaround for the flicker problem with frequently-updated elements.

Bugfixes since v1.3:
- NaviUtilities::decodeURIComponent previously failed to properly decode certain sequences, this has been resolved.
Ah, I also forgot to mention that all callbacks now require a signature of "void function(NaviData naviData)" instead of "void function(const NaviData &naviData)".

The NaviDemo has been thoroughly updated to make good use of the new API changes, so you can look to it for reference.


For those itching to update to the latest SVN, I'll go over a few basics of the new NaviData system:

Essentially NaviData now acts like a big std::map<std::string, NaviDataValue>. The new class, 'NaviDataValue' is really a generic container for the following explicit types: wide string, string, boolean, integer, float, double. So you can do something like this:

Code: Select all

NaviDataValue myValue = 79.14;
std::string numberString = myValue.str();
We can then extend this thinking to the NaviData object:

Code: Select all

NaviData myData("TestData");
myData["isHappy"] = "true"; 

// Some time else
bool happy = myData["isHappy"].toBool(); // "true" & "false" are interpreted as their numeric equivalent
Data validation (does the key exist?) can now be performed via:

Code: Select all

bool ensure(const std::string &key, bool throwOnFailure = true);

&

bool ensure(const std::vector<std::string> &keys, bool throwOnFailure = true);
To additionally validate that the value of the key is numeric (can be converted to a Number), simply prefix the name of the key with "#".

Code: Select all

void myCallback(NaviData naviData)
{
	vector<string> myKeys;
	myKeys.push_back("name");
	myKeys.push_back("#age");

	naviData.ensure(myKeys);

	int age = naviData["age"].toInt();

	cout << "Hello " << naviData["name"].str() << std::endl;
	cout << "You are " << age << " years old!" << std::endl;	
}
Obviously that "push_back" business is really ugly, oh if only there was an easy way to declare string vectors inline. Oh wait, I'm a programmer, duh:

Code: Select all

naviData.ensure(Strings("name")("#age"));
NaviUtilities::Strings is a typedef for NaviUtilities::InlineVector<std::string>, look at NaviUtilities.h for more info.

Having to execute 'naviData.ensure' inside the callback is sometimes too annoying. Thus, you may optionally specify a string vector of keys to validate as the last parameter of NaviManager::bind. (previously named NaviManager::bindNaviData)


Okay, onwards to Navi.js!

MooTools v1.11 is now embedded inside Navi.js (for ease of inclusion as the new implementation depends upon it).

Old syntax of sending NaviData:

Code: Select all

new NaviData("chatMessage").add("nick", "Bob").add("msg", "Hello world!").send();
New syntax:

Code: Select all

new NaviData("chatMessage", {nick: "Bob", msg: "Hello world!"}).send();

OR

$ND("chatMessage", {nick: "Bob", msg: "Hello world!"}).send();
If you want to be really lazy, I like to use this new feature:

Code: Select all

<form id="myForm">
<input name="nick" type="text"></input>
<input name="msg" type="text"></input>
</form>

<div id="myButton" onclick="$ND('chatMessage', $('myForm')).send()">Send Message</div>
Old syntax of retrieving values from Page NaviData:

Code: Select all

if(pageNaviData.doesExist("msg"))
    document.write("We got a message:  " + pageNaviData.get("msg"));
New syntax:

Code: Select all

if($defined($PND.get("msg")))
    document.write("We got a message:  " + $PND.get("msg"));

When the page's DOM is ready (so you can start executing Javascript from the application), a NaviData object named 'ready' is sent. You can bind a callback to this for data initialization purposes.

There is a ComboBox implementation (as a workaround for our problems with native comboboxes) and also Element.setHTMLBuffered (as a workaround for flicker with frequently-updated elements).


A ton of work has gone into these changes, I hope you'll find some of them pleasing. Yes, the API has been broken, but for a good cause. :wink: If you have any questions, comments, or concerns, I'll be happy to reply.

Enjoy.
Lord LoriK
Goblin
Posts: 254
Joined: Tue Feb 13, 2007 5:33 am

Post by Lord LoriK »

Hmmm... nice changes. I'm fixing my code to adapt to the broken interface. Here's a few suggestions:

* NaviData::toStringMap() should be made const so you can use it in the onNaviDataEvent() callback. This requires converting the iterator to const_iterator, and...

* With the same arguments, I'd make const the following NaviDataValue methods: wstr(), str(), isEmpty(), isNumber(), toInt(), toFloat(), toDouble(), toBool().

* This changes allow callbacks with the old signature:

Code: Select all

void function(const NaviData &naviData)
which are a lot more efficient than copying the whole argument so many times. I might be missing something (I'm not using callbacks myself), but I think the two changes above are all you need.

* Give two versions of Navi.js: one readable with comments for debuging/development, and one compressed for release. A 200k script can hit the performance of Navi loading.

I hope you don't mind the ideas.
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

Lord LoriK wrote:Hmmm... nice changes. I'm fixing my code to adapt to the broken interface. Here's a few suggestions:

* NaviData::toStringMap() should be made const so you can use it in the onNaviDataEvent() callback. This requires converting the iterator to const_iterator, and...

* With the same arguments, I'd make const the following NaviDataValue methods: wstr(), str(), isEmpty(), isNumber(), toInt(), toFloat(), toDouble(), toBool().

* This changes allow callbacks with the old signature:

Code: Select all

void function(const NaviData &naviData)
which are a lot more efficient than copying the whole argument so many times. I might be missing something (I'm not using callbacks myself), but I think the two changes above are all you need.

* Give two versions of Navi.js: one readable with comments for debuging/development, and one compressed for release. A 200k script can hit the performance of Navi loading.

I hope you don't mind the ideas.
Suggestions accepted and committed to the SVN, the actual hurdle for NaviData being const was the subscript operator. I hadn't realized you could do a const overload for it, but that's all taken care of now. :D

Function signatures for NaviDelegates are now back to normal (void function(const NaviData &naviData)).


As for the JS minification, I had planned on doing exactly that using JSMin for the next release. A quick run through its algorithm tells me that Navi.js can be packed down to 83k~.

(Of course, we can compress it further in exchange for a loss in performance via Dean Edwards Packer, down to about 46k~. But that's just silly, considering our context.)
Lord LoriK
Goblin
Posts: 254
Joined: Tue Feb 13, 2007 5:33 am

Post by Lord LoriK »

Hehehe! That was fast! That's why I love this GUI so much!
Post Reply