Team Spartan Cookies & Milk Forums
  • Issue Tracker
  • Donations
  • Search
  • Member List
  • Help

Register

Team Spartan Cookies & Milk Forums Garry's Mod Starfall v
« Previous 1 … 5 6 7 8 9 … 18 Next »
Release Alteran framework
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pages (2): 1 2 Next »
Threaded Mode
Release Alteran framework
02-06-2014, 12:55 PM,
#1
Cobra Offline
Moderator
*****
Posts: 306
Threads: 18
Joined: Oct 2013
Alteran framework
Alteran Framework

This framework is still in an on going work in progress. While the implemented features already work and can be used by everyone, the framework is continuously growing with new features beeing added.
At the moment the Framework focuses on the UI module (Starfall screens). Other modules will be added afterwards.


1. Introduction
2. Framework core documentation
3. UI Module


1. Introduction
1.1 What is the Alteran Framework?
The Alteran Framework is a Starfall framework, that tries to make using and implementing code inside of Starfall chips much easier.
This framework is being developed by trying to keep everything as simple and extendable as possible.
Which makes the framework very easy and intuitive to use and gives more advanced programmers the possibility to add their own stuff or hook into the code, without having to change the code of the framework itself.
Also since I am developing a lot of stuff in C# and javascript, you will find some patterns from these languages applied to the framework.

1.2 Where to get it
The framework can be downloaded ingame from my shared Starfall folder.
Inside the "Alteran" folder do right click on "framework.txt" and hit "Download Package".
Optionally you can download the "testFramework.txt" file from my shared folder too. It shows how the framework works with some nice examples.

1.3 A small code sample
This is a small code sample to show how easy it is to develope with the Alteran Framework:
if CLIENT then
-- Creates a touch enabled button on the screen
local button = Alteran.UI.Controls.Button.New("BtnTest", {
X = 10, -- X position on the screen
Y = 100, -- Y position on the screen
OnClick = OnButtonClick -- Callback function that gets called when someone presses the button
})
end

2. Framework core documentation
2.1 The frameworks architecture
The framework is built modular. Which means you can decide for yourself which parts of the framework you need for your starfall chip.
This reduces ops and also reduces the amount of resources loaded. The different framework modules are inside seperate folders.

For example the "UI" module, which contains everything related to starfall screens is in its own subfolder called "ui".

Also the framework tries to mimic the behiavor of objects (at least as far as it is possible in Lua). So every file usually holds a class (for example the "Button" class).
Every module has its own Namespace under the root Alteran namespace (for example "Alteran.UI" for the ui module. Everything contained in a module is below that namespace.

2.2 How to include and load the framework in your code
To include the framework you only need 2 lines of code:
--@include Alteran/framework.txt
require("Alteran/framework.txt")
After you have included the framework file you need to tell the framework which modules you want to load:
Alteran.LoadCoreModule()
Alteran.LoadUIModule()
Always make sure to load the Core System before you load any other modules.
You can find the specific command to load a certain module in the documentation of said module.

If you included the framework correctly and loaded the modules, you should see some messages in your console. The framework logs most of the stuff to the console.

2.3 Direct members of the Alteran namespace
There are a few things that are located directly in the Alteran namespace which get loaded when you load the core system.
All these utilities are located in the "utilities" folder of Alteran.

2.3.1 The Frameworks cache
There is a cache inside the Alteran namespace that holds some tables that might be used frequently and use ops to load.
Following entities are cached:
  • Alteran.Owner: The player object of the starfall chips owning player
  • Alteran.Players: Holds a list of all players currently on the server. Gets refreshed automatically when a player leaves or joins

2.3.2 Alteran.CollisionCheck
This is a small utility containing some algorithms do check if a certain point is insde an object.
  • Alteran.CollisionCheck.IsInBox(point, box): A function that checks wether a certain 2D point is inside a 2D box.
    Parameters:
    • point: A vector 2D object holding X and Y coordinates
    • box: The box object containing X and Y coordiantes and Width and Height properties
2.3.3 Alteran.Vector2D
Holds the Vector2D class.
  • Alteran.Vector2D.New(x,y): Creates a new Vector2D object and returns it
  • Alteran.Vector2D.DotProduct(v1, v2): Calculates the DotProduct between two vectors.
  • Alteran.Vector2D.GetSegment(v1, v2): Calculates the Delta vector between two vectors.

Following functions are available on the Vector2D object:
  • vector:Normalize(): Creates a new vector that has the same angle as the current one, but a length of 1
  • vector:GetNormal(): Gets a new vector that is orthogonal to the current vector

2.3.4 Functions directly nested in the Alteran namespace
  • Alteran.CreateColor(r, g ,b, a): Creates a new starfall color object with the given RGBA values
  • Alteran.PrintToConsole(message): Prints the given message to the console
  • Alteran.PrintToChat(message): Prints the given message to private chat
  • Alteran.PrintError(message): Prints the given error to the console
  • Alteran.PrintErrorMsgToChat(message): Prints the given message to private chat
  • Alteran.Clone(t): Clones a given table and returns it.
  • Alteran.ExpandTable(t1, t2): Expands a table with another one. All properties in t2 that are not contained in t1 are beeing added from t2 to t1

2.4 The concept of prototyping
This framework uses or tries to mimic a concept called "Prototyping" from Javascript.
What it does is basically define how an object looks like and define default values for all the properties on the object.
Let's take the example of a button on a starfall screen. This button has the properties "X" and "Y".
Now everytime you create a new button using
Alteran.UI.Control.Button.New("ButtonID", { parameter1 = 10, parameter2 = 0, ... })
you overwrite the default value of the property "parameter1" on the button, while the property "parameter3" will still have its default value defined on the prototype.
For the more experienced users of lua: The brackets "{ ... }" create a new table with the properties given inside the brackets. These properties overwrite the default properties defined in the prototype table of the object. Every class in Alteran has a prototype.

This makes it possible to only define the properties you would like and use default values for all other properties.
Furthermore the code gets much easier to read and is easy to understand and maintain.

3. UI Module
3.1 Module description
The UI module is the module that handles everything related to Starfall screens (and maybe later also Emitters and HUDs).
It contains several prebuilt controls you can use on your screen and can be easily customised with user defined styles.
You can find an example of a small demo starfall screen in the "testFramework.txt" file in my shared folder.

3.2 How to load the module
To load the module you only need to call
Alteran.LoadUIModule()
Note that the core module needs to be loaded first.

3.3 Controls
The UI module holds several different controls. Every control is an isolated object and renders itself. The UI module holds track of all added controls and makes sure that they get rendered.

3.3.1 Label
A label is the most simplest control in this module. It simply renders a text on screen. You can create a new Label using:
Alteran.UI.Controls.Label.New("LabelID", { parameters... }

Possible parameters:
    Alteran.UI.Controls.Label.Prototype = {
X = 0, -- The X position on the screen
Y = 0, -- The Y position on the screen
Style = {
Font = Alteran.UI.Style.DefaultFont, -- Defines the font to use with this label
TextColor = Alteran.UI.Style.TextColor -- Defines the text color to use for this label
},
Text = "Label" -- The text to display
}

3.3.2 OpsCounter
The OpsCounter is used to show you the used ops on the screen.
You can create an OpsCounter control using:
Alteran.UI.Controls.OpsCounter.New("OpsCounterID", { parameters... })

Possible parameters:
    Alteran.UI.Controls.OpsCounter.Prototype = {
X = 0, -- The X position on the screen
Y = 0, -- The Y position on the screen
Mode = "Percent" -- Display Mode. Use "Percent" to show percentage usage, or "Absolute" to show absolute ops usage
}

3.3.2 Button
The button control is as the name already implies a touchscreen enabled button on a starfall screen. It has callbacks for hover and click.
You can create a button control using:
Alteran.UI.Controls.Button.New("ButtonID", { parameters ... })

Possible parameters:
    Alteran.UI.Controls.Button.Prototype = {
X = 0, -- The X position on the screen
Y = 0, -- The Y position on the screen
Style = {
Font = Alteran.UI.Style.DefaultFont, -- Font to use for the button's text
TextColor = Alteran.UI.Style.TextColor, -- Color to use for the button's text
Border = Alteran.UI.Style.Border, -- The border definition to use for the button (contains BorderColor)
HighlightedBackgroundColor = Alteran.UI.Style.HighlightedBackgroundColor -- The background color to use for highlighted button
},
Width = 150, -- The width of the button
Height = 30, -- The height of the button
Text = "Button", -- Text to display on the button
PublicAccess = false, -- If true, allows all people to use the button, if false only owner can use it
OnHover = nil, -- Callback function to call when someone hovers over the button
OnClick = nil, -- Callback function to call when someone presses on the button
}

Callbacks (Events):
  • OnHover(): Gets called when a player hovers over the button
  • OnClick(pressedPlayer, clickedButton): Gets called when a player presses on the button

3.4 Customizing the style
The UI module allows you to define your own style (colors, sizes, ...).
You can define a global style that every control uses, or you can define a style for only one specific control.

3.4.1 Customizing the global style
The global style can be set using:
Alteran.UI.Style = yourStyle
Where "yourStyle" is a lua table looking as following:
{
BackgroundColor = Alteran.CreateColor(0, 0, 0),
HighlightedBackgroundColor = Alteran.CreateColor(0, 0, 128),
Font = "Arial",
FontSize = 20,
HeaderFont = "Arial",
HeaderFontSize = 30,
TextColor = Alteran.CreateColor(255, 255, 255),
Border = { BorderColor = Alteran.CreateColor(0, 0, 255) }
}

3.4.2 Customizing the style for one control instance only
Every control beeing rendered by the UI module has the property "Style".
To change the appearance of the control you can either overwrite the table "Style" of the control using:
button.Style = yourStyle
or
button.Style.styleProperty = yourValue

As an alternative you can also define the style while creating the instance of the control:
local yourControl = Alteran.UI.Controls.SomeControl.New("ID", { Style = yourStyle, ... })

  • ASUS R.O.G. Rampage IV Black Edition
  • 2x Fury X
  • Intel Core i7 4930K OC @ 4.4GHz
  • Corsair H100i
  • Samsung SSD 850 Series 1TB
  • Samsung SSD 830 Series 512GB
  • Western Digital 512GB HDD
  • 32GB DDR3 2400MHz RAM (G.Skill TridentX)
  • Corsair 900D
Website Find
Reply
02-06-2014, 02:01 PM,
#2
pho Offline
once you go pho you never go back
***
Posts: 578
Threads: 82
Joined: Oct 2013
RE: Alteran framework
wat
wat

u are ronondex from cap team ?
Website Find
Reply
02-06-2014, 02:11 PM,
#3
Cobra Offline
Moderator
*****
Posts: 306
Threads: 18
Joined: Oct 2013
RE: Alteran framework
No phoeniiiix. I am not that RononDex Tongue Seems like a funny coincidence Big Grin

  • ASUS R.O.G. Rampage IV Black Edition
  • 2x Fury X
  • Intel Core i7 4930K OC @ 4.4GHz
  • Corsair H100i
  • Samsung SSD 850 Series 1TB
  • Samsung SSD 830 Series 512GB
  • Western Digital 512GB HDD
  • 32GB DDR3 2400MHz RAM (G.Skill TridentX)
  • Corsair 900D
Website Find
Reply
02-06-2014, 02:46 PM,
#4
pho Offline
once you go pho you never go back
***
Posts: 578
Threads: 82
Joined: Oct 2013
RE: Alteran framework
oh okay

and what this "framerwork" does ?
Website Find
Reply
02-06-2014, 02:53 PM,
#5
Cobra Offline
Moderator
*****
Posts: 306
Threads: 18
Joined: Oct 2013
RE: Alteran framework
It will provide a lot of funcitonality that is often used when you code Starfall. The first version will focus on a better screen library.

For example if you want to add a tochscreeen enabled button to your screen you can then write something like this:

Alteran.UI.Controls.Button(x, y, text, style, callback_function, ...)
-- or
Alteran.UI.Controls.Label(x, y, text, style)

As it says in the first post it will make coding with Starfall much easier.

  • ASUS R.O.G. Rampage IV Black Edition
  • 2x Fury X
  • Intel Core i7 4930K OC @ 4.4GHz
  • Corsair H100i
  • Samsung SSD 850 Series 1TB
  • Samsung SSD 830 Series 512GB
  • Western Digital 512GB HDD
  • 32GB DDR3 2400MHz RAM (G.Skill TridentX)
  • Corsair 900D
Website Find
Reply
02-06-2014, 04:47 PM,
#6
busterbeej332 Offline
Valued donator and member
****
Posts: 111
Threads: 28
Joined: Nov 2013
RE: Alteran framework
nice will make codeing alot easyer
Find
Reply
02-06-2014, 09:14 PM,
#7
Cobra Offline
Moderator
*****
Posts: 306
Threads: 18
Joined: Oct 2013
RE: Alteran framework
Alright, the first version is now online! I published to github and gmod server (public code repository).
Documentation will follow in the next few days.

At the moment all it supports is a simple label + a ops counter.

You can see a demonstration on how to use them in the "testFramework.txt" file.

  • ASUS R.O.G. Rampage IV Black Edition
  • 2x Fury X
  • Intel Core i7 4930K OC @ 4.4GHz
  • Corsair H100i
  • Samsung SSD 850 Series 1TB
  • Samsung SSD 830 Series 512GB
  • Western Digital 512GB HDD
  • 32GB DDR3 2400MHz RAM (G.Skill TridentX)
  • Corsair 900D
Website Find
Reply
02-09-2014, 07:00 PM,
#8
Cobra Offline
Moderator
*****
Posts: 306
Threads: 18
Joined: Oct 2013
RE: Alteran framework
I have started working on the framework again. Expect some awesome features in the next few days or so Tongue

  • ASUS R.O.G. Rampage IV Black Edition
  • 2x Fury X
  • Intel Core i7 4930K OC @ 4.4GHz
  • Corsair H100i
  • Samsung SSD 850 Series 1TB
  • Samsung SSD 830 Series 512GB
  • Western Digital 512GB HDD
  • 32GB DDR3 2400MHz RAM (G.Skill TridentX)
  • Corsair 900D
Website Find
Reply
05-11-2015, 07:46 PM,
#9
Cobra Offline
Moderator
*****
Posts: 306
Threads: 18
Joined: Oct 2013
RE: Alteran framework
Finally, the first public version is now released!
Feel free to use it, give feedback, critise, reports bugs, place feature requests or whatever you want to do Wink

Also the documentation of the current version has been done more or less. There are still some missing parts about how to add your own controls or hook into the framework.
This will be added at a later time.
Also as this is the first release, it does not hold a lot of features atm. The framework will grow over time!

  • ASUS R.O.G. Rampage IV Black Edition
  • 2x Fury X
  • Intel Core i7 4930K OC @ 4.4GHz
  • Corsair H100i
  • Samsung SSD 850 Series 1TB
  • Samsung SSD 830 Series 512GB
  • Western Digital 512GB HDD
  • 32GB DDR3 2400MHz RAM (G.Skill TridentX)
  • Corsair 900D
Website Find
Reply
06-11-2015, 03:01 AM,
#10
TheOneAndOnlyTee Offline
GMod Admin
Posts: 755
Threads: 47
Joined: Oct 2013
RE: Alteran framework
Nice work, when i get a chance i'll mess around with it. Smile

Steam Profile
My Discord Server
Need help with E2 or SF? , just ask me and i'll try to help.
[Image: 98Dkcoz.gif]
Find
Reply
« Next Oldest | Next Newest »
Pages (2): 1 2 Next »


  • View a Printable Version
Forum Jump:


Users browsing this thread: 1 Guest(s)
Contact UsTeam Spartan Cookies & MilkReturn to TopLite (Archive) ModeMark all forums readRSS Syndication

Powered By MyBB, © 2002-2026 MyBB Group.