Login

russian armor

[SCAR] UI Control API

22 Aug 2015, 17:26 PM
#1
avatar of eliw00d
Honorary Member Badge

Posts: 756 | Subs: 8

Relic recently introduced UI Control, which allows modders to create custom UI in SCAR. While working on the custom UI for our mod, Fortress Europe, I came up with an API that made using the UI Control much faster and simpler. I decided to polish it a little bit and release it publicly, for others to benefit from.

It is based on Object Oriented Programming, so it is very versatile. You can create sub classes that inherit from my classes, if you would like. This will allow you to create many different kinds of elements for your custom UI.

The Documentation is a work-in-progress, and I am open to Pull Requests on GitHub.

https://github.com/eliw00d/UIControlAPI

Here is a brief overview of the UI Control API. I will make a more in-depth video at some point.

22 Aug 2015, 23:38 PM
#2
avatar of IronMedic

Posts: 318

To use localised strings your mod needs, a burn folder containing a "language".ucs


Example localised strings for english.ucs

1 Incendiary Cluster Bomb
2 IncendiaryClusterBomb
3 +%1AMOUNT%:MP\n +%2AMOUNT%:MU\n +%3AMOUNT%:FU



To references a localised string replace the string whit "$uniqueModID:lineInLocaleLanguageFile".
The example below references the third line/string in the local "language".ucs.

g_textString = "$3106b71c884f41eaa8434de9c91bf9cc:3"
23 Aug 2015, 00:04 AM
#3
avatar of eliw00d
Honorary Member Badge

Posts: 756 | Subs: 8

I did not know it would work with a string, thanks!
23 Aug 2015, 18:18 PM
#4
avatar of eliw00d
Honorary Member Badge

Posts: 756 | Subs: 8

Turns out the Relic functions do the type checking for you, so you can pass the setText functions an Integer or a String with the following formats:

Integer
<LocStringID>

String
"$<ModID>:<LocStringID>"
"$<LocStringID>"

I have updated the code as a result.
23 Aug 2015, 20:44 PM
#5
avatar of eliw00d
Honorary Member Badge

Posts: 756 | Subs: 8

I have added a Wiki:

https://github.com/eliw00d/UIControlAPI/wiki

Detailed descriptions for methods coming soon, but it should get you started.
3 Sep 2015, 21:05 PM
#6
avatar of eliw00d
Honorary Member Badge

Posts: 756 | Subs: 8

Added a temporary fix to the Label class's setFontSize method, which should help with Labels getting offset downwards, leading to cut off. Set size and location first, and font size last. Height should be 1:1 with the font size for this to work.

An example:
Code
label = Label("Label");
label.setSize(128, 16);
label.setLocation(8, 8);
label.setFontSize(label.getHeight() or 16);


Let me know if there are any issues. Otherwise, let's hope that Relic fixes the issue!
18 Nov 2015, 16:52 PM
#7
avatar of eliw00d
Honorary Member Badge

Posts: 756 | Subs: 8

I have just uploaded Version 2.0, which adds a new Class function and changes the syntax of method calls. I also cleaned up the code quite a bit, which should improve performance and efficiency.

An updated example:

Code
label = Label("Label");
label:setSize(128, 16);
label:setLocation(8, 8);
label:setFontSize(label.getHeight() or 16);


The change from . to : is due to the methods hiding the self variable. For those not familiar with this syntax:

Code
function Label:setSize(width, height)


is the same as

Code
function Label.setSize(self, width, height)


So, you should only have to update your own code to reflect the change in syntax, the rest should be the same.

Please let me know if you have any questions or concerns. Thanks and enjoy!
1 user is browsing this thread: 1 guest

Ladders Top 10

  • #
    Steam Alias
    W
    L
    %
    Streak
Data provided by Relic Relic Entertainment

Replay highlight

VS
  • U.S. Forces flag cblanco ★
  • The British Forces flag 보드카 중대
  • Oberkommando West flag VonManteuffel
  • Ostheer flag Heartless Jäger
uploaded by XXxxHeartlessxxXX

Board Info

351 users are online: 351 guests
3 posts in the last 24h
44 posts in the last week
141 posts in the last month
Registered members: 44899
Welcome our newest member, otorusgfgy
Most online: 2043 users on 29 Oct 2023, 01:04 AM