OmniEngine.Net
OmniEngine.Net copied to clipboard
ObjectCreator is uglyyyy.
I really wanna clean up object creation.
new A() { new B(){}; };
Is just syntactic sugar for:
new A() {};
new B() {};
A.add(B);
So instead of this:
oc_Newobject4["#Newobject1"] = oc_Newobject1;
We could have this:
SimSet set = oc_Newobject4.create();
set.add(oc_Newobject1.create());
And we should use named parameters in the constructors so that instead of this:
ObjectCreator oc_Newobject4 = new ObjectCreator("GuiWindowCtrl", "ConsoleDlgWindow", typeof (ConsoleDlgWindow));
oc_Newobject4["isContainer"] = "1";
oc_Newobject4["AllowPopWindow"] = "1";
We should have:
// Have to have GuiWindowCtrl constructor in a seperate class to avoid boilerplate constructors in
// classes derived from GuiWindowCtrl.
GuiWindowCtrl oc_Newobject4 = new GuiWindowCtrlInstance(name: "ConsoleDlgWindow", isContainer: true, AllowPopWindow: true);
// Alternately
GuiWindowCtrl oc_Newobject4 = (new GuiWindowCtrlInstance("ConsoleDlgWindow")
{
isContainer = true,
AllowPopWindow = true
}).create();
Dynamics is ofc an issue, this could be handled through a "dynamics" parameter which could be a key-value pair or something.
Is that second TS-style constructor valid C#? What must I search for to read about this wizardry?
Yeah, I guess we could set up dynamics, haven’t messed with them lately though
From: Daniel Buckmaster [mailto:[email protected]] Sent: Friday, January 09, 2015 6:47 PM To: Winterleaf/OmniEngine.Net Subject: Re: [OmniEngine.Net] ObjectCreator is uglyyyy. (#19)
Is that second TS-style constructor valid C#? What must I search for to read about this wizardry?
— Reply to this email directly or view it on GitHub https://github.com/Winterleaf/OmniEngine.Net/issues/19#issuecomment-69421495 . https://github.com/notifications/beacon/ACUNZAOhJ85qMws7alAuYUfMck3BQOVkks5ngF_fgaJpZM4DQk0O.gif
@eightyeight this bit?
GuiWindowCtrl oc_Newobject4 = (new GuiWindowCtrlInstance("ConsoleDlgWindow")
{
isContainer = true,
AllowPopWindow = true
}).create();
It's basically the same as doing oc_Newobject4.isContainer = true etc. after initialization It's just syntactic sugar, and it is valid C# ;)
Edit: Oh, source
As an example of the syntactical difference:
ObjectCreator oc = new ObjectCreator("SimGroup", "MeshQualityGroup", typeof (QualityGroup));
ObjectCreator ao1 = new ObjectCreator("ArrayObject", "[Lowest]", typeof (GraphicsQualityLevel));
ao1["class"] = "GraphicsQualityLevel";
ao1["caseSensitive"] = true;
oc["#1"] = ao1;
oc.Create();
Will become:
SimGroup group = new SimGroupInstance(name: "MeshQualityGroup");
ArrayObject array = new ArrayObjectInstance(name: "[Lowest]",
class: "GraphicsQualityLevel",
caseSensitive: true);
group.add(array);
so Lukas, this is all for readability, not any new functionality correct? how long do u think this would take to accomplish (pure curiosity)
On Fri, Jan 9, 2015 at 8:11 PM, Lukas Joergensen [email protected] wrote:
As an example of the syntactical difference:
ObjectCreator oc = new ObjectCreator("SimGroup", "MeshQualityGroup", typeof (QualityGroup)); ObjectCreator ao1 = new ObjectCreator("ArrayObject", "[Lowest]", typeof (GraphicsQualityLevel)); ao1["class"] = "GraphicsQualityLevel"; ao1["caseSensitive"] = true; oc["#1"] = ao1; oc.Create();
Will become:
SimGroup group = new SimGroupInstance(name: "MeshQualityGroup"); ArrayObject array = new ArrayObjectInstance(name: "[Lowest]", class: "GraphicsQualityLevel", caseSensitive: true);group.add(array);
— Reply to this email directly or view it on GitHub https://github.com/Winterleaf/OmniEngine.Net/issues/19#issuecomment-69429340 .
Paul Yoskowitz [image: http://]about.me/paulyoskowitz http://about.me/paulyoskowitz?promo=email_sig
Yeah just for readability, I don't know how long it would take.. It depends on the generator that Vince is fumbling with, it doesn't take an awful lot of time to make the implementation for just e.g. SimObjects but if you need it for all classes and all future code it might take some time.. @Winterleaf (Vince) would probably be better at answering that than me :)
well vince is in the middle of game code atm is why I asked ya :)
and its your suger ;)
On Fri, Jan 9, 2015 at 8:25 PM, Lukas Joergensen [email protected] wrote:
Yeah just for readability, I don't know how long it would take.. It depends on the generator that Vince is fumbling with, it doesn't take an awful lot of time to make the implementation for just e.g. SimObjects but if you need it for all classes and all future code it might take some time.. @Winterleaf https://github.com/Winterleaf (Vince) would probably be better at answering that than me :)
— Reply to this email directly or view it on GitHub https://github.com/Winterleaf/OmniEngine.Net/issues/19#issuecomment-69430906 .
Paul Yoskowitz [image: http://]about.me/paulyoskowitz http://about.me/paulyoskowitz?promo=email_sig
Well, I might be able to achieve this on my own:
SimGroup group = new SimObjectInstance("MeshQualityGroup");
ArrayObject array = new SimObjectInstance("[Lowest]")
{
class = "GraphicsQualityLevel",
caseSensitive = true
};
group.add(array);
But that will be without intellisense. Anything more than that will need to be written into the project generator.
hmm.... is that out on github?
On Fri, Jan 9, 2015 at 8:33 PM, Lukas Joergensen [email protected] wrote:
Well, I might be able to achieve this on my own:
SimGroup group = new SimObjectInstance("MeshQualityGroup"); ArrayObject array = new SimObjectInstance("[Lowest]") { class = "GraphicsQualityLevel", caseSensitive = true };group.add(array);
But that will be without intellisense. Anything more than that will need to be written into the project generator.
— Reply to this email directly or view it on GitHub https://github.com/Winterleaf/OmniEngine.Net/issues/19#issuecomment-69431683 .
Paul Yoskowitz [image: http://]about.me/paulyoskowitz http://about.me/paulyoskowitz?promo=email_sig
@chieling Is what on Github? The generator?
https://github.com/Winterleaf/OmniEngine.Net
I remember there being a tools folder and didn't remember if the generator code was in there or snot.
On Fri, Jan 9, 2015 at 8:47 PM, Lukas Joergensen [email protected] wrote:
@chieling https://github.com/chieling Is what on Github? The generator?
— Reply to this email directly or view it on GitHub https://github.com/Winterleaf/OmniEngine.Net/issues/19#issuecomment-69432551 .
Paul Yoskowitz [image: http://]about.me/paulyoskowitz http://about.me/paulyoskowitz?promo=email_sig
Afaik thats not in there.
ah ok
On Fri, Jan 9, 2015 at 9:04 PM, Lukas Joergensen [email protected] wrote:
Afaik thats not in there.
— Reply to this email directly or view it on GitHub https://github.com/Winterleaf/OmniEngine.Net/issues/19#issuecomment-69433375 .
Paul Yoskowitz [image: http://]about.me/paulyoskowitz http://about.me/paulyoskowitz?promo=email_sig
So Lukas, do u need anything? or can u test and work with what u got?
On Fri, Jan 9, 2015 at 9:12 PM, Paul Yoskowitz < [email protected]> wrote:
ah ok
On Fri, Jan 9, 2015 at 9:04 PM, Lukas Joergensen <[email protected]
wrote:
Afaik thats not in there.
— Reply to this email directly or view it on GitHub https://github.com/Winterleaf/OmniEngine.Net/issues/19#issuecomment-69433375 .
Paul Yoskowitz [image: http://]about.me/paulyoskowitz http://about.me/paulyoskowitz?promo=email_sig
Paul Yoskowitz [image: http://]about.me/paulyoskowitz http://about.me/paulyoskowitz?promo=email_sig
I can probably make an exapmle implementation, but we'll need to edit the codegenerator for a proper implementation. And I still don't have access to that afaik :P