Hey,

On Wed, Jul 18, 2012 at 10:27 PM, Liviu Andronic <liv-public@myopera.com> wrote:
On Wed, 18 Jul 2012 22:05:17 +0200, Jasmine Kent <jk@codeartemis.com>
wrote:

> The time value in seconds is actually stored as a string in the XML, so
> you'll need to convert it to a float first because that's what formatTime
> expects. You could use the "atof" (ascii to float) function or similar,
>
Excellent! It's in now. Please check r86 for proper coding style.

Iwan, could you check to see if all is as expected?

Thanks for adding the time info!
FYI: r86 compiles and runs on both 64 and 32 bit Arch Linux.


Cheers
Liviu


> eg formatTime(atof(targettime)) or formatTime(atof(targettime.c_str())).
>
> http://www.cplusplus.com/reference/clibrary/cstdlib/atof/
>
> - Jasmine
>
> On Wed, Jul 18, 2012 at 5:51 PM, Liviu Andronic
> <liv-public@myopera.com>wrote:
>
>> On Tue, 17 Jul 2012 17:15:18 +0200, Jasmine Kent <jk@codeartemis.com>
>> wrote:
>>
>>  Looking at the pseudo-xml in your first mail, I would expect that
>> <level>
>>> is the root element, and you need to access the targettime attribute of
>>> the
>>> <race> child element. I'm afraid I can't remember how to do that in
>>>
>>
>>
>>  TinyXml, sorry, but it shouldn't be too complicated and there are
>> probably
>>> examples of how to do it elsewhere in the code.
>>>
>>>  I almost nailed it. I found one such example in game.cpp line 103 so
>>> now
>> the menu displays the target time, but only in seconds (as specified in
>> the
>> config file). I tried to convert it to formatted time using
>> PUtil::formatTime(val), but compilation failed. Any suggestions how to
>> tackle this?
>> src/trigger/main.cpp: In member function ‘bool MainApp::loadLevel(**
>> TriggerLevel&)’:
>> src/trigger/main.cpp:407: error: no matching function for call to
>> ‘PUtil::formatTime(const char*&)’
>> src/trigger/../pengine/**pengine.h:123: note: candidates are: static
>> std::string PUtil::formatTime(float)
>>
>> Below is the latest implementation.
>>
>> Liviu
>>
>> root@liv-laptop:/home/liv/**Build/trigger/src/trigger# svn diff
>>
>> Index: main.cpp
>> ==============================**==============================**=======
>> --- main.cpp    (revision 85)
>> +++ main.cpp    (working copy)
>> @@ -382,6 +382,7 @@
>>    tl.name = "Untitled";
>>    tl.comment = "";
>>    tl.author = "";
>> +  tl.targettime = "";
>>
>>    TiXmlDocument xmlfile(tl.filename.c_str());
>>    TiXmlElement *rootelem = PUtil::loadRootElement(**xmlfile, "level");
>> @@ -398,6 +399,15 @@
>>
>>    if (val) tl.comment = val;
>>    val = rootelem->Attribute("author");
>>    if (val) tl.author = val;
>> +  for (TiXmlElement *walk = rootelem->FirstChildElement();
>> +    walk; walk = walk->NextSiblingElement()) {
>> +
>> +    if (!strcmp(walk->Value(), "race")) {
>> +      val = walk->Attribute("targettime");
>>
>> +      if (val) tl.targettime = val;
>> +
>> +    }
>> +  }
>>
>>
>>    return true;
>>  }
>> Index: menu.cpp
>> ==============================**==============================**=======
>> --- menu.cpp    (revision 85)
>> +++ menu.cpp    (working copy)
>> @@ -265,6 +265,8 @@
>>      gui.addLabel(250.0f,450.0f, levels[lss.currentlevel].name,
>> PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 30.0f);
>>      gui.addLabel(200.0f,400.0f, "Author", PTEXT_HZA_RIGHT |
>> PTEXT_VTA_TOP, 30.0f);
>>      gui.addLabel(250.0f,400.0f, levels[lss.currentlevel].**author,
>> PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 30.0f);
>> +    gui.addLabel(200.0f,350.0f, "Time", PTEXT_HZA_RIGHT |
>> PTEXT_VTA_TOP,
>> 30.0f);
>> +    gui.addLabel(250.0f,350.0f, levels[lss.currentlevel].**targettime,
>> PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 30.0f);
>>      gui.makeDefault(
>>        gui.makeClickable(
>>          gui.addLabel(400.0f,100.0f, "START RACE", PTEXT_HZA_CENTER |
>> PTEXT_VTA_CENTER, 40.0f),
>> Index: main.h
>> ==============================**==============================**=======
>> --- main.h      (revision 85)
>> +++ main.h      (working copy)
>> @@ -122,7 +122,7 @@
>>
>>
>>  struct TriggerLevel {
>> -  std::string filename, name, comment, author;
>> +  std::string filename, name, comment, author, targettime;
>>  };
>>
>>  struct TriggerEvent {
>>


--
Using Opera's revolutionary email client: http://www.opera.com/mail/

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
trigger-rally-devel mailing list
trigger-rally-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/trigger-rally-devel