Ingame GUI

20 replies [Last post]
Posts: 1003
CP: 7799

Any tips on where I should start if I want to add a GUI ingame (windows + functionality, change the appearance, ...)?

Posts: 1003
CP: 7799

I kinda miss the vbGORE community Sad it was so helpful back in the day...

Anyways, I've started a tutorial on editing the GUI, feel free to improve it
[[Adding your own gui]]

Posts: 1647
CP: 26119

Well, you should elaborate on WHAT you want to change. The graphics? The layout? The behaviors?

Posts: 1003
CP: 7799

I wasn't asking for how to make it do something. I was just asking for some guidelines to what needs to be added where in the code to add things (aka what I wrote on the wiki page).

Also on a more off topic related note the server doesn't seem to be saving the location when someone logs out anymore :/

Posts: 1647
CP: 26119

Well the GUI process pretty much involves:
1. Create a new control derived from an existing control (e.g. an inventory screen derived from a Form)
2. Override components to make it behave as needed
3. Attach it wherever it is needed. For those shown in the game screen, like the inventory, its done in the GameplayScreen class during InitGUI() or something like that.
4. If you want to save the settings of the window, attach it to the GUISettingsManager using a unique key (see the existing code).

The user position thing is intentional. Being able to log in right where you logged out can be incredibly abusive. But if you want it back, just update the load_x and load_y db values when the user moves, as long as they are moving on a map that is not instanced.

Posts: 1003
CP: 7799

Ah I see Smile I'll be adding all that to the wiki page somewhere next week.

As for the user position, what was the idea behind it? I can't think of a real way someone could abuse it. All MMORPGs I've played always logged me back in where I logged out.

Posts: 1647
CP: 26119

If you have places where items spawn and usually involve fighting your way to it (like the end of a maze of labyrinth), you can just start up right next to it. Or, if you have PvP and someone logs out, a fellow PvP-er can wait for them to come back since they know the exact spot and you can't exactly make the whole part of every map non-PvP. Then there are issues of spawning on top of monsters, in the way of attacks, etc.

Though have to keep in mind I don't really play MMOs. Most of my experience comes from small indy games, and the gameplay mechanics are quite a bit different.

Posts: 1003
CP: 7799

Ah, I see you've got a point there. That reminds me, in addition of being invincible for 3 seconds after a battle in SVO, when a user logs in I should make him invincible for 3 seconds as well although that could be abused to get through an area with monsters. Would probably add it so it only does that once an hour or so.

Posts: 11
CP: 0

Or only after being logged out for, let's say, 15 minutes. That's long enough to make abusing it very boring. Smile
You can also do something like WoW does: require the player to wait for 20 seconds (or so) from he clicks Exit until he's "removed" from the game world. The player can still force the game to close during that time, but he remains present in the game world, and is vulnerable and attackable both by NPCs and players.

Posts: 164
CP: 0

Skye wrote:
Ah, I see you've got a point there. That reminds me, in addition of being invincible for 3 seconds after a battle in SVO, when a user logs in I should make him invincible for 3 seconds as well although that could be abused to get through an area with monsters. Would probably add it so it only does that once an hour or so.

You could also add another constraint to where once they move the invincibility is gone. Just a thought.

Posts: 180
CP: 0

Perfect World International does this as well.

That would probably be the best way to go.

Posts: 95
CP: 0

thought I'd post in this thread then make my own as I'm having a bit of troubles with GUI (yes still >.< ain't been very motivated with netgore since meeting).

 class FishForm : Form
    {
        public FishForm(Control parent, Vector2 pos) : base(parent, pos, new Vector2(600, 750))
        {
            Position = pos;
        }
 
        protected override void SetDefaultValues()
        {
            base.SetDefaultValues();
            Text = "Fishing";
        }
        protected override void UpdateControl(TickCount currentTime)
        {
            base.UpdateControl(currentTime);
 
            if (!IsVisible)
                return;
        }
   }

I have a basic form implanted (stripped some code and comments out so easy to view on form). In game the form is there however it seems like its stuck at 100 by 100 size, I changed the base value to 600 by 750 however this doesn't seem be having any effect. I ripped the code from the other forms so if I'm understanding right that's the way to change the size of the form however it is evidently not changing any ideas?

Posts: 1647
CP: 26119

Are you saving the settings of the form? If so, try deleting the GUI settings by just deleting all of \bin\.

Posts: 95
CP: 0

at the moment I am not saving the settings of the GUI, deleted the bin folder but no such luck >.<

Posts: 1647
CP: 26119

Hmm, then I am not sure why you'd be having a problem with it resizing down, and 100x100 seems like a pretty random size. Make sure ResizeToChildren is set to false, and that the control the form is in is not too small (or just set IsBoundToParentArea to false). You might want to try re-setting the size again after setting this values.

Posts: 95
CP: 0

Spodi wrote:
Hmm, then I am not sure why you'd be having a problem with it resizing down, and 100x100 seems like a pretty random size. Make sure ResizeToChildren is set to false, and that the control the form is in is not too small (or just set IsBoundToParentArea to false). You might want to try re-setting the size again after setting this values.

hmm that would probably be it, my form doesn't have a control which would be why its so small, I looked over statForm.cs and skillform.cs e.t.c and it doesn't look like the form is being assigned to any control am I looking in the wrong place or miss understanding you.

Posts: 1647
CP: 26119

The StatForm and SkillForm, along with any other form on the GameplayScreen, all use a Panel control as the top-level control that covers the whole screen. Same goes for all other screens. It makes it easy to restrict the child controls to the visible area this way, and also allows you to move or resize the whole UI (in case you'd ever want to do that for some reason).

Posts: 95
CP: 0

well cScreen (think thats the panel) is not too small. I've tried making my form to 1 pixel by 1 pixel but nothings happened ever, seems like its ignoring any request to resize it >.<.

In gameplay screen I've created a new instance of the form (_cScreen, new Vector2(200, 200) and added it to the guisettings, am I suppose to do something else?

Posts: 1647
CP: 26119

Try not adding it to the GUISettings. If that doesn't work, try posting your whole class.

Posts: 95
CP: 0

O.k now it works when I don't add it to the gUI settings >.< thanks Spodi, I'll try and take a look at why it doesn't like being added to GUI settings now,

Posts: 1647
CP: 26119

It sounds like its for the reason I mentioned before. When you add a form to the GUISettings, or any other control, it saves the last state of the control for quite a few variables. The size of the form is one of these. So if you do not add the size to the SetDefaultValues(), and only the constructor, the size you end up giving to the constructor will behave like the default size, and the saved size in the settings will be used instead if it exists.