Turbo Badger implementation

Share your helpful Urho3D code snippets, samples and tutorials here.

Turbo Badger implementation

PostPosted by thebluefish » 14 Sep 2015, 16:00

I've had this for over a month now, and progress has been slow. I don't foresee any modifications that I need to do to the port itself, so I feel confident enough in releasing this. However this implementation makes several assumptions that will not be true for everyone, so some modification may be required to fit your specific needs.

This is primarily based off the existing Urho3D UI implementation, so there will be a lot of similarities.

It still uses Urho3D resources to load files, so turbobadger file paths are the same as loading any files through Urho3D. I did hard-code the skin and override skin paths in TBUI.cpp, so you may need to change these if you use different paths.

Image
Turbo Badger running in Urho3D in a wxWidgets window.


TBUI.h:
Code: Select all
>>Removed<<


TBUI.cpp:
Code: Select all
>>Removed<<


To setup the subsystem:
Code: Select all
// Setup Turbo Badger UI
UI::TBUI::RegisterSystem(_context);
_context->RegisterSubsystem(new UI::TBUI(_context));
_context->GetSubsystem<UI::TBUI>()->Init();


Adding an editor control that expands the entire window is easy:
Code: Select all
_editorUI = ui->LoadWidget<tb::TBWidget>("UI/ui_resources/editor_tab_content.tb.txt");
ui->SetRoot(_editorUI);
Last edited by thebluefish on 03 Nov 2015, 21:54, edited 2 times in total.
something something signature here

Code: Select all
DVIS_> i just formatted the only copy of my pgp master and recovery keys
User avatar
thebluefish
Most active user
Most active user
 
Posts: 367
Joined: 14 Apr 2014, 03:25
Location: United States

Re: Turbo Badger implementation

PostPosted by rasteron » 15 Sep 2015, 00:05

Great share! :)
User avatar
rasteron
Have many posts
Have many posts
 
Posts: 437
Joined: 07 Mar 2014, 07:46
Location: web

Re: Turbo Badger implementation

PostPosted by carnalis » 18 Sep 2015, 16:04

Excellent, thanks blue 8-)

diff from tb_config.h
Code: Select all
35c35
< #define TB_FONT_RENDERER_TBBF
---
> //#define TB_FONT_RENDERER_TBBF
38c38
< //#define TB_FONT_RENDERER_FREETYPE
---
> #define TB_FONT_RENDERER_FREETYPE
102c102
< #define TB_FILE_POSIX
---
> //#define TB_FILE_POSIX
107c107
< #define TB_FILE_POSIX
---
> //#define TB_FILE_POSIX
112c112
< #define TB_FILE_POSIX
---
> //#define TB_FILE_POSIX


Initialize subsystem (assuming similar namespace setup):
Code: Select all
  // Setup Turbo Badger UI
  context_->RegisterSubsystem(new App::UI::TBUI(context_));
  context_->GetSubsystem<App::UI::TBUI>()->Init();
Last edited by carnalis on 22 Sep 2015, 01:25, edited 2 times in total.
<Patrician|Away> what does your robot do, sam
<bovril> it collects data about the surrounding environment, then discards it and drives into walls
User avatar
carnalis
Moderator
Moderator
 
Posts: 180
Joined: 21 Jan 2014, 19:00
Location: United States

Re: Turbo Badger implementation

PostPosted by thebluefish » 18 Sep 2015, 16:41

A little example to working with events, including input.

Working with Carnalis' example, your class needs to inherit from TBWidgetListener and set itself as a global event handler. This example is for clicking a button called "fileMenu", and showing a popup window with the File menu options:

Code: Select all
bool Editor::OnWidgetInvokeEvent(tb::TBWidget *widget, const tb::TBWidgetEvent &ev)
{
   if (ev.target->GetID() == tb::TBID("fileMenu"))
   {
      if (ev.type == tb::EVENT_TYPE_CLICK)
      {
         static tb::TBGenericStringItemSource source;
         if (!source.GetNumItems())
         {
            source.AddItem(new tb::TBGenericStringItem("New", tb::TBID("default font")));
            source.AddItem(new tb::TBGenericStringItem("Open File", tb::TBID("large font")));
            source.AddItem(new tb::TBGenericStringItem("-"));
            source.AddItem(new tb::TBGenericStringItem("Save", tb::TBID("large font")));
            source.AddItem(new tb::TBGenericStringItem("Save All", tb::TBID("large font")));
            source.AddItem(new tb::TBGenericStringItem("-"));
            source.AddItem(new tb::TBGenericStringItem("Exit", tb::TBID("align left")));
         }

         if (tb::TBMenuWindow *menu = new tb::TBMenuWindow(widget, tb::TBID("popup_menu")))
         {
            menu->Show(&source, tb::TBPopupAlignment());
         }
      }
   }
}
something something signature here

Code: Select all
DVIS_> i just formatted the only copy of my pgp master and recovery keys
User avatar
thebluefish
Most active user
Most active user
 
Posts: 367
Joined: 14 Apr 2014, 03:25
Location: United States

Re: Turbo Badger implementation

PostPosted by carnalis » 28 Sep 2015, 16:23

https://github.com/fruxo/turbobadger
Very slick UI :D
Candidate for Urho3D? I really like the way TurboBadger does things, it seems rather complete, internationalized..
Last edited by carnalis on 08 Feb 2016, 21:11, edited 3 times in total.
<Patrician|Away> what does your robot do, sam
<bovril> it collects data about the surrounding environment, then discards it and drives into walls
User avatar
carnalis
Moderator
Moderator
 
Posts: 180
Joined: 21 Jan 2014, 19:00
Location: United States

Re: Turbo Badger implementation

PostPosted by carnalis » 21 Oct 2015, 22:29

A TurboBadger Console (Urho3D::Object, TBWidget) inspired by Urho3D::Console.

Image

Still a couple rough edges..
Being a TBWidget, it's easily styled and modified. I did not implement SetNumLines() (calc the line height) but it shouldn't be hard.

Besides Urho3D's Console, the TurboBadger Demo application was helpful in developing this, and can offer a lot of insight.

After instantiating TBUI and creating a root widget..
Code: Select all
Console* console(new ::Console(context_, tbRoot));
console->LoadResourceFile("UI/resources/console.txt"); // required widgets
console->Initialize();
// Change custom styles for LOG_* constants (output widget in console.txt has 'styling 1')..
console->styleMap_[LOG_ERROR] = Pair<String, String>("<color #ff0000>", "</color>");
console->Toggle(); // It's invisible by default

console->SetID(TBIDC("console"));
// Can be later retrieved by ID:
// Console* console(static_cast<Console*>(tbRoot->GetWidgetByID(TBIDC("console"))));


Console.h
https://gist.github.com/carnalis/2761431647bda9c90b4d

Console.cc
https://gist.github.com/carnalis/6fbc1202729f21f6c153

console.txt
TurboBadger widget definition file; leading tabs are significant.https://gist.github.com/carnalis/baa26a0943c684c4b8a9
Last edited by carnalis on 05 Nov 2015, 15:41, edited 2 times in total.
<Patrician|Away> what does your robot do, sam
<bovril> it collects data about the surrounding environment, then discards it and drives into walls
User avatar
carnalis
Moderator
Moderator
 
Posts: 180
Joined: 21 Jan 2014, 19:00
Location: United States

Re: Turbo Badger implementation

PostPosted by Lumak » 01 Nov 2015, 09:52

I'm looking at your code and Atomic's code for the first time, and it looks like you copied and pasted Atomics code. From rendering process to key inputs, they're identical.

Well, I guess it's ok if you gave him credit for his work.

Wow, I'm surprize to see Atomic's UIInput.cpp file is almost as long as my entire integration.
Lumak
Have many posts
Have many posts
 
Posts: 425
Joined: 08 Jun 2015, 15:38

Re: Turbo Badger implementation

PostPosted by thebluefish » 02 Nov 2015, 15:01

Lumak wrote:I'm looking at your code and Atomic's code for the first time, and it looks like you copied and pasted Atomics code. From rendering process to key inputs, they're identical.

Well, I guess it's ok if you gave him credit for his work.

Wow, I'm surprize to see Atomic's UIInput.cpp file is almost as long as my entire integration.


Input stuff I got from Atomic. Rendering stuff was based on Urho3D's existing UI class. The reason our code base looks similar is because we both used UI as our base. However Atomic uses a functionally different batching process which I skipped altogether. I actually finished the rendering part before I took a look at Atomic, but I got stuck on "proper" input support and filesystem stuff.
something something signature here

Code: Select all
DVIS_> i just formatted the only copy of my pgp master and recovery keys
User avatar
thebluefish
Most active user
Most active user
 
Posts: 367
Joined: 14 Apr 2014, 03:25
Location: United States

Re: Turbo Badger implementation

PostPosted by Lumak » 03 Nov 2015, 15:44

I see. It would've been nice to see a reference.
Lumak
Have many posts
Have many posts
 
Posts: 425
Joined: 08 Jun 2015, 15:38

Re: Turbo Badger implementation

PostPosted by jenge » 03 Nov 2015, 19:48

I am glad that some of the Atomic code was useful.

I don't really mind for snippets, though when sharing in the "Code Exchange" section for others to use, probably a good idea to leave copyright and license notifications in place ;)
User avatar
jenge
Some active
Some active
 
Posts: 72
Joined: 27 Apr 2014, 15:42
Location: United States

Next

Return to Code Exchange

Who is online

Users browsing this forum: No registered users and 1 guest

cron