Adam's Lair Forum

game development and casual madness
It is currently 2020/02/25, 04:26

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: 2015/02/17, 13:07 
Forum Addict
Forum Addict
User avatar

Joined: 2013/09/19, 14:31
Posts: 883
Location: Italy
Role: Hobbyist
I am developing a small utility for the editor, and I need to have access to some of the default resources for debugging.

I thought it would have been enough to add
Code:
Duality.DualityApp.Init(Duality.DualityApp.ExecutionEnvironment.Launcher, Duality.DualityApp.ExecutionContext.Game);

inside my Main, but the resources are always null.

What am I missing?

full code
Code:
[STAThread]
static void Main()
{
  Application.EnableVisualStyles();
  Application.SetCompatibleTextRenderingDefault(false);
  Duality.DualityApp.Init(Duality.DualityApp.ExecutionEnvironment.Launcher, Duality.DualityApp.ExecutionContext.Game);

  WidgetSkin ws = new WidgetSkin()
  {
    Material = Duality.Resources.Material.DualityLogoBig // <-- This is always null
  };

  Application.Run(new SnowyPeak.Duality.Editor.Plugin.Frozen.UI.Forms.SkinEditor(ws));
}

_________________
Come on Duality's Discord channel. We have cookies! :mrgreen:


Top
 Profile  
 
PostPosted: 2015/02/17, 16:04 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 2073
Location: Germany
Role: Professional
Init is not enough - it just does the basic groundwork and makes Duality usable, but as long as there is no OpenGL context, etc. no Resources can be loaded. That's why Duality setup requires at least two steps: Init and - after the context is available - InitGraphics.

There are two examples you can look into:

  • The DualityLauncher does all the basic setup in Main, but also a lot of stuff that isn't definitely needed. Still, it's a starting point.
  • For Unit Testing, Duality is also initialized completely. You can find the init code here.

Honestly, I haven't yet found a way to get OpenTK to provide a working OpenGL context without either a GameWindow or a GLControl, which is why Unit Testing opens up a dummy window. :rly:

This is all but shiny and great, but it works for now and is kind of a rare use case as well. However, if you do need to build a tool without some rendering area, you could experiment with the unit testing init a little more and see if you find a way.

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
PostPosted: 2015/02/17, 16:11 
Forum Addict
Forum Addict
User avatar

Joined: 2013/09/19, 14:31
Posts: 883
Location: Italy
Role: Hobbyist
Thanks,

in fact, I have already found InitGraphics but I didn't understand exactly how it works.. getting a lot of MemoryAccess exceptions..

that's ok though, for the moment I am debugging with other kind of data, and I am pretty confident that it will only be a matter of switching to the correct Resource type in the end and everything will click together (the last famous words.. :mrgreen: )

One more question though.. this will be a simple GUI to define Skins for my Widgets without the need to type all values by hand (I'm getting tired of doing that for my game :D), so I added a new editor action where I will pass my Skin resource to my new Form.

once I finish, will it be enough to assign the modified Resource's values back to the original one, or do I have to do something else?

my idea:
Code:
public class EditorActionEditSkin : EditorSingleAction<WidgetSkin>
{
  ...
  public override void Perform(WidgetSkin skin)
  {
    SkinEditor se = new SkinEditor(skin);
    if(se.ShowDialog() == DialogResult.OK)
    {
      skin = se.ModifiedSkin;
    }
  }     
}

_________________
Come on Duality's Discord channel. We have cookies! :mrgreen:


Top
 Profile  
 
PostPosted: 2015/02/17, 16:20 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 2073
Location: Germany
Role: Professional
SirePi wrote:
once I finish, will it be enough to assign the modified Resource's values back to the original one, or do I have to do something else?


Notify the editor about the properties you changed! DualityEditorApp.NotifyPropertyChanged is your friend. ;)

SirePi wrote:
my idea:
Code:
public class EditorActionEditSkin : EditorSingleAction<WidgetSkin>
{
  ...
  public override void Perform(WidgetSkin skin)
  {
    SkinEditor se = new SkinEditor(skin);
    if(se.ShowDialog() == DialogResult.OK)
    {
      skin = se.ModifiedSkin;
    }
  }     
}


Doesn't sound too bad. One alternative would be to make the editor Window non-modal and available as a DockContent at all times, but programmed to adjust to the current editor selection. Not better than your idea, but different.

All that said, I'm a little worried now.. :eh: I assumed you were working on an external tool, since you need to initialize Duality, but knowing that you're extending the actual Duality editor, you definitely should not need to initialize anything. Or I probably misunderstood what you're doing :question:

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
PostPosted: 2015/02/17, 16:25 
Forum Addict
Forum Addict
User avatar

Joined: 2013/09/19, 14:31
Posts: 883
Location: Italy
Role: Hobbyist
Adam wrote:
Notify the editor about the properties you changed! DualityEditorApp.NotifyPropertyChanged is your friend. ;)

I knew I was forgetting something :mrgreen:

Adam wrote:
All that said, I'm a little worried now.. :eh: I assumed you were working on an external tool, since you need to initialize Duality, but knowing that you're extending the actual Duality editor, you definitely should not need to initialize anything. Or I probably misunderstood what you're doing :question:

Ah, yes.. it will be inside the editor, but for the moment I am opening the form from a simple project - just referencing Duality dlls. I just wanted to try to debug it with the real Resources, anyway just a simple bitmap is enough for me (it's what I will be extracting from the Material anyway)

Duality is safe for now :D

_________________
Come on Duality's Discord channel. We have cookies! :mrgreen:


Top
 Profile  
 
PostPosted: 2015/02/17, 16:33 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 2073
Location: Germany
Role: Professional
SirePi wrote:
Ah, yes.. it will be inside the editor, but for the moment I am opening the form from a simple project - just referencing Duality dlls.


Ah, now it makes sense. :D For a quick hack to see stuff in action, you could also set up a "test plugin" for the editor that just brings up some UI in the actual environment. Not sure if that helps any, just an idea. Though if you have an existing testing setup, it's probably easier to stick to it.

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group