Page 2 of 2

Re: what is the stack of BGA?

Posted: 06 February 2021, 23:42
by thoun
I updated my stack to use Typescript & scss (with local build instead of dirty PHP build I previously mentionned).

If you're interested, I explained it on the Readme file on Github project page.

I'll add it to BGA studio wiki documentation later for those interested. I haven't find a way yet to split my code into multiple files, so I want to polish it before sharing.

Re: what is the stack of BGA?

Posted: 07 February 2021, 00:24
by Tisaac
thoun wrote: 06 February 2021, 23:42 I updated my stack to use Typescript & scss (with local build instead of dirty PHP build I previously mentionned).

If you're interested, I explained it on the Readme file on Github project page.

I'll add it to BGA studio wiki documentation later for those interested. I haven't find a way yet to split my code into multiple files, so I want to polish it before sharing.
Splitting scss files is easy, you can do an import in your main file and the scss compiler merge everything into one css file.
For the js part, it would be great if webpack could work hand in hand with dojo builds.

Re: what is the stack of BGA?

Posted: 07 February 2021, 11:50
by Archduke
For splitting js files, I put various functions into different files, and then attach them to the main class in the constructor.
It's a bit unusual, but I find it simpler this way, and it means you can arbitrarily split the code how you like.

This does mean having multiple files on the server, but when it comes to deploying live, I can just copy them all into one file (or write a script for it at some point.)

Example:

Code: Select all

define([
	"dojo","dojo/_base/declare",
	"ebg/core/gamegui",

	g_gamethemeurl + "modules/gamename.states.js",
],
function (dojo, declare, gamegui, states) {
	return declare("bgagame.gamename", gamegui, {
		constructor: function(){
				console.log('gamename constructor');
				...
				this.onEnteringState = states.onEnteringState.bind(this);
				this.onLeavingState = states.onLeavingState.bind(this);
				...
		},
	});
});
And gamename.states.js just defines the required functions:

Code: Select all

function onEnteringState( stateName, args ) {
	console.log( 'Entering state: '+stateName );
	
	switch( stateName )
	{
	case 'dummmy':
		break;
	}
}

function onLeavingState( stateName ) {
	console.log( 'Leaving state: '+stateName );
	
	switch( stateName )
	{
	case 'dummmy':
		break;
	}
}

define({ onEnteringState, onLeavingState });

Re: what is the stack of BGA?

Posted: 08 February 2021, 09:55
by thoun
That's nice for JS stack.
I updated my conf so now in can split my TS files, and it automatically builds in a single JS file :)

Re: what is the stack of BGA?

Posted: 08 February 2021, 10:18
by Tisaac
Archduke wrote: 07 February 2021, 11:50 For splitting js files, I put various functions into different files, and then attach them to the main class in the constructor.
It's a bit unusual, but I find it simpler this way, and it means you can arbitrarily split the code how you like.

This does mean having multiple files on the server, but when it comes to deploying live, I can just copy them all into one file (or write a script for it at some point.)
That's a bit cumbersome if you want to do something similar to php trait.
I personnaly like to use multi inheritance of dojo class that allow me to use all the function as if it was inside the main class itself, but I didn't manage to make a proper build yet.

Re: what is the stack of BGA?

Posted: 08 February 2021, 15:27
by thoun
thoun wrote: 08 February 2021, 09:55 That's nice for JS stack.
I updated my conf so now in can split my TS files, and it automatically builds in a single JS file :)
I created a wiki page to explain how I set up auto-build for my Typescript and SCSS files.

Re: what is the stack of BGA?

Posted: 10 February 2021, 05:45
by shapeshifter999
Wow! Thank you very much everybody! It was a lot of information! It sure that I love typescript support and able to split one large file into multiple files.

Self-diary:

I just discovered that PHP has some typing.
I was able to run tests inside of PhpStorm.

I am currently investigating the page->begin_block and page->insert_block to see if it is possible to create multiple tpl files:
team.tpl
round.tpl
...

and insert them into self::getGameName() . "_" . self::getGameName() .tpl file.

Thank for your support!

Re: what is the stack of BGA?

Posted: 10 February 2021, 07:53
by Tisaac
sderrico wrote: 10 February 2021, 05:45 Wow! Thank you very much everybody! It was a lot of information! It sure that I love typescript support and able to split one large file into multiple files.

Self-diary:

I just discovered that PHP has some typing.
I was able to run tests inside of PhpStorm.

I am currently investigating the page->begin_block and page->insert_block to see if it is possible to create multiple tpl files:
team.tpl
round.tpl
...

and insert them into self::getGameName() . "_" . self::getGameName() .tpl file.

Thank for your support!
Honestly, that's probably useless, just use a bunch of js template instead, you will need some dynamic content anyway.

Re: what is the stack of BGA?

Posted: 10 February 2021, 15:10
by shapeshifter999
Honestly, that's probably useless, just use a bunch of js template instead, you will need some dynamic content anyway.
Thanks for the tip! I will drop this investigation :)