Zhanxueyou / RbrPro-Addons

A simple test add-on for the RBRPro Manager

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RbrPro-Addons

First of all, what the hell is RBRPro? Discover it here https://www.rbrpro.org

Want to develop an addon for the RBRPro manager? Welcome to the right place!

Since version 0.3.0.0 the RBRPro Manager supports Add-Ons. A NGP6 Telemetry "router" has been implemented and the support for Add-ons has been added. An add-on can become a client and receive telemetric data from the manager.

In other words, the RBRPro Manager behaves in a way which is very similar to SimHub (do you know it?). It receives the NGP telemetry from the game via UDP protocol and provides the data to its add-ons. An add-on is basically a WPF Control hosted in the Add-Ons tab of the manager.

A working example is provided. It is a complete Add-On with the following features:

  • Uses the TGD Localization engine to translate its GUI according to the language selected in the manager
  • Uses the Lightweight TGD MVVM framework for data binding and configuration persistence
  • Receives the telemetry and visualizes the car speed in real time
  • Starts the game from a command Button

Some ideas for a new addon? Here are some hints...

  • Hosting a new championship with its own calendar and rankings
  • Implementing a driver for a dynamic simulator
  • Implementing a co-driver engine (yes... TGD Navigator will be an addon...)
  • A custom on-screen overlay
  • A new online plugin...

How to start

To compile the solution you will need to reference the TGD.Common.dll and the RBRPro.API.dll contained in your RBRPro installation root directory. Both the RBRPro.API and the TestAddon project makes use of the TGD.Common.dll classes (TGD.Localization and TGD.Framework above all). Select the folder <RBRPro>/Addons as the destination directory for the compiled files (where <RBRPro> is the root directory).

About

TGD Localization Engine (TGD.Localization.Localizer)

This is a small framework I wrote to allow the language switch in RBRPro... and you know how well it works! :)
After evaluating other solutions, I've come to the conclusion that they didn't have the features I was looking for and decided to make my implementation. My localization engine is really simple to use but light and powerful at the same time. It make use of the "Tag" and "ToolTip" properties. The language file is a simple .ini file. The Load() method of the Localizer class loads the iniFile into a C# Dictionary. When you set Tag="SectionName. PropertyName" in the XAML, you are telling the engine to retrieve the property "PropertyName" in the section "SectionName" of its current language definition. Once loaded the dictionary, the Localizer's Translate() method translates the GUI by a recursive traversal of the WPF LogicalTree, starting from the element you provide as the root (usually the main window or control). For convenience, I use a static class as a "proxy" for the Localizer, so that i can recall it from whatever point in the code.

TGD ContextManager (TGD.Framework.DynamicContextManager)

This class is simple and sophisticated at the same time. It provides a convenient way to implement your view Model providing two kinds of properties: Config and Runtime properties, implemented respectively by the special attributes [RuntimeProperties] and [ConfigProperties]. Both the kinds of properties are "Observables" and then they are "ready" for WPF data binding. The class allows the use of multiple configuration files as well.
[ConfigProperties] are automatically loaded and saved. You can use only simple C# types but this is not a big limitation. The [RuntimeProperties] are instead the "volatile" ones. There is no limitation in their type, they can be also data Collections. Together with the ObservableCollection class provided by the TGD.Framework package these classes are a good starting point to develop WPF based applications. Typically, you will set an instance of your implementation of the ContextManager as the GUI's DataContext.

Add-ons

An Add-on module for RBRPro is a .NET based .dll class library exposing one or more classes implementing the IRbrProAddOn interface. The manager provides an object called interactor which allows the interaction between the Add-On and the host application. The interactor exposes a DOM referencing the main business entities. It also provide special events such as LanguageChanged that the Add-on can use to "react" to what is happening in the manager. Each DOM entity is definend by an interface (IDriver, ICar, IStage, ICoDriver and so on).

Licensing

You are free to download and use this code for any non-commercial purposes. For commercial usage please contact info.rbrpro@gmail.com

About

A simple test add-on for the RBRPro Manager


Languages

Language:C# 100.0%