![]() |
|
Release Alteran framework - Printable Version +- Team Spartan Cookies & Milk Forums (https://teamscm.co.uk) +-- Forum: Garry's Mod (https://teamscm.co.uk/forum-4.html) +--- Forum: Starfall (https://teamscm.co.uk/forum-7.html) +--- Thread: Release Alteran framework (/thread-325.html) Pages:
1
2
|
Alteran framework - Cobra - 02-06-2014 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:
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:
After you have included the framework file you need to tell the framework which modules you want to load:
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:
2.3.2 Alteran.CollisionCheck This is a small utility containing some algorithms do check if a certain point is insde an object.
Holds the Vector2D class.
Following functions are available on the Vector2D object:
2.3.4 Functions directly nested in the Alteran namespace
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
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
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:
Possible parameters:
3.3.2 OpsCounter The OpsCounter is used to show you the used ops on the screen. You can create an OpsCounter control using:
Possible parameters:
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:
Possible parameters:
Callbacks (Events):
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:
Where "yourStyle" is a lua table looking as following:
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:
or
As an alternative you can also define the style while creating the instance of the control:
RE: Alteran framework - pho - 02-06-2014 wat wat u are ronondex from cap team ? RE: Alteran framework - Cobra - 02-06-2014 No phoeniiiix. I am not that RononDex Seems like a funny coincidence
RE: Alteran framework - pho - 02-06-2014 oh okay and what this "framerwork" does ? RE: Alteran framework - Cobra - 02-06-2014 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:
As it says in the first post it will make coding with Starfall much easier. RE: Alteran framework - busterbeej332 - 02-06-2014 nice will make codeing alot easyer RE: Alteran framework - Cobra - 02-06-2014 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. RE: Alteran framework - Cobra - 02-09-2014 I have started working on the framework again. Expect some awesome features in the next few days or so
RE: Alteran framework - Cobra - 05-11-2015 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 ![]() 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! RE: Alteran framework - TheOneAndOnlyTee - 06-11-2015 Nice work, when i get a chance i'll mess around with it.
|