RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Gump Editor

JonnyBrav

Wanderer
crazyseamonkey said:
Just want to say I got a look at this program already (Thanks Bradley) and it's looking awesome...I can't wait for it to be finished...it already blows most of the other editors out of the water and it's not finished yet.

Exactly :)
 

Bradley

Sorceror
I am currently working on moving the "snap to grid" feature into a plugin. I will post the source code and instruction on compiling the plugin to give an idea of what kinds of things can be done with the system.
 

Bradley

Sorceror
Plugin Example

This is the source code for a Gump Studio plugin. It is actually 2 plugins working together to create the snap to grid feature.

The first plugin, SnapToGrid, Adds a menu "Show Grid" that toggles on or off the grid of dots in the designer. It also hooks into the mouse movement code to watch for element dragging, and alters the mouse coord to snap it to the grid when the shift key is held down. It also installs another plugin, SnapToGridExtender, which gets placed into each type of Element. This plugin adds the "snap to grid" context menu to elements when they are right clicked.

The code would be compiled into a DLL, and placed into the "Plugins" folder next to the GumpDesigner.exe.

I'll try to come up with a better tutorial on creating plugins once I officially release the edit.

[code:1]Imports Gump_Designer
Imports Gump_Designer.Plugins
Imports System.Drawing


Public Class SnapToGrid
Inherits BasePlugin

Protected mDesigner As DesignerForm
Protected mExtender As SnapToGridExtender
Protected mShowGrid As Boolean = False
Protected mShowGridMenu As System.Windows.Forms.MenuItem

Public Overrides Function GetPluginInfo() As Gump_Designer.Plugins.PluginInfo
Dim Info As New PluginInfo
Info.AuthorEmail = "**********"
Info.AuthorName = "Bradley Uffner"
Info.Description = "Allows elements to be snapped to an 8x8 grid."
Info.PluginName = "SnapToGrid"
Info.Version = "1.0"
Return Info
End Function

Public Overrides Sub Load(ByVal frmDesigner As Gump_Designer.DesignerForm)
mDesigner = frmDesigner
If mExtender Is Nothing Then mExtender = New SnapToGridExtender(mDesigner)

mShowGridMenu = New System.Windows.Forms.MenuItem("Show Grid", AddressOf DoToggleGridMenu)
frmDesigner.mnuPlugins.MenuItems.Add(mShowGridMenu)
AddHandler mDesigner.PreRender, AddressOf RenderGrid
End Sub

Public Overrides ReadOnly Property Name() As String
Get
Return GetPluginInfo.PluginName
End Get
End Property

Public Overrides Sub InitializeElementExtenders(ByVal Element As Gump_Designer.Elements.BaseElement)
Element.AddExtender(mExtender)
End Sub

Public Overrides Sub MouseMoveHook(ByRef e As Gump_Designer.Plugins.MouseMoveHookEventArgs)
If e.MoveMode = MoveModeType.Move AndAlso CBool(e.Keys And Windows.Forms.Keys.Shift) Then
e.MouseLocation = mExtender.SnapToGrid(e.MouseLocation, mExtender.GridSize)
End If
End Sub

Public Sub DoToggleGridMenu(ByVal sender As System.Object, ByVal e As System.EventArgs)
mShowGrid = Not mShowGrid
mShowGridMenu.Checked = mShowGrid
mDesigner.picCanvas.Refresh()
End Sub

Public Sub RenderGrid(ByVal Target As Bitmap)
If mShowGrid Then
For x As Integer = 0 To mDesigner.picCanvas.Width - 1 Step mExtender.GridSize.Width 'DrawGird
For y As Integer = 0 To mDesigner.picCanvas.Height - 1 Step mExtender.GridSize.Height
Target.SetPixel(x, y, Color.LightGray)
Next
Next
End If
End Sub
End Class

Public Class SnapToGridExtender
Inherits Plugins.ElementExtender

Public GridSize As Size = New Size(8, 8)
Protected mDesigner As DesignerForm

Public Sub New(ByVal Designer As DesignerForm)
mDesigner = Designer
End Sub

Public Overridable Sub DoSnapToGridMenu(ByVal sender As System.Object, ByVal e As System.EventArgs)
For Each o As Object In mDesigner.ElementStack.GetSelectedElements
Dim Element As Elements.BaseElement = CType(o, Elements.BaseElement)
Element.Location = SnapToGrid(Element.Location, GridSize)
Next
End Sub

Public Function SnapToGrid(ByVal Position As Point, ByVal GridSize As Size) As Point
Dim NewPoint As Point = Position
NewPoint.X = CInt(NewPoint.X \ GridSize.Width) * GridSize.Width
NewPoint.Y = CInt(NewPoint.Y \ GridSize.Height) * GridSize.Height
Return NewPoint
End Function

Public Overrides Sub AddContextMenus(ByRef GroupMenu As System.Windows.Forms.MenuItem, ByRef PositionMenu As System.Windows.Forms.MenuItem, ByRef OrderMenu As System.Windows.Forms.MenuItem, ByRef MiscMenu As System.Windows.Forms.MenuItem)
If PositionMenu.MenuItems.Count > 1 Then
PositionMenu.MenuItems.Add(New System.Windows.Forms.MenuItem("-"))
End If
PositionMenu.MenuItems.Add(New System.Windows.Forms.MenuItem("Snap to Grid", AddressOf DoSnapToGridMenu))
End Sub
End Class[/code:1]
 

Bradley

Sorceror
Nagash said:
I thought so :(

Send me an icq message, I can get you a preview. Just know that it's only about 30% done at this point, so lots of stuff isn't finished, or things will change from in the release version
 

Anatol

Wanderer
missing

I have played a bit with Gump editors in only the lat few weeks and am pretty new to them. So if it as possibe to have a small help file for the noobs out there that would love to learn ;).
 

Bradley

Sorceror
Re: missing

Anatol said:
I have played a bit with Gump editors in only the lat few weeks and am pretty new to them. So if it as possibe to have a small help file for the noobs out there that would love to learn ;).
A website is being built for the Editor that will have full tutorials on using the editor, and building plugins for it. I currently have 3 people working on plugins, each of them in a different .NET language, so there should be some good examples of how to write plugins.

My SnapToGrid plugin is written in VB.NET
Someone is translating SnapToGrid into C#
and I also have a plugin that can export gumps to Wolfpack format, that plugin is written in Managed c++.

Using the editor is very easy, it's all drag and drop with the mouse. I've tried to make the interface look like Visual studio, so if you have used that then Gump Studio should be simple.
 

Daegon

Wanderer
I have also written a plugin that will export the gump to a shell C# script, and am working on the idea from earlier in the thread to copy the gump initialization to clipboard.

Go bradley! =)
 

Bradley

Sorceror
Version 1.0!

Verion 1.0 of Gump Studio has been released, You can download it here. If you find any bugs pelase let me know, and I will try to get them fixed as soon as possable. Thanks to everyone who helped me find the bugs, and to those who gave me some suggestions to improve the editor, Gump Studio couldn't be what it is if everyone hadn't helped. An extra special thanks goes out to those who wrote the two export plugins that come with the editor, you guys rule!

Enjoy!
~Bradley
 

loops

Wanderer
How does the snap to grid work in this? I would love to use it, but it doesnt show the grid for me even if i have it selected.
 

Bradley

Sorceror
loops said:
How does the snap to grid work in this? I would love to use it, but it doesnt show the grid for me even if i have it selected.

use the plugin managet and make sure that snaptogrid is listed after wallpepr, otherwise the wallpaper draws over top of the grid.
You can hold down the shift key while dragging to snap to the grid, or you can right click an element to snap it to theg rid.
 
Top