2009-04-19 18:07:22 +00:00
#region = = = = = = = = = = = = = = = = = = Copyright ( c ) 2007 Pascal vd Heiden
/ *
* Copyright ( c ) 2007 Pascal vd Heiden , www . codeimp . com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* /
#endregion
#region = = = = = = = = = = = = = = = = = = Namespaces
using System ;
using System.Collections.Generic ;
using System.ComponentModel ;
2015-07-01 23:09:34 +00:00
using System.Diagnostics ;
2009-04-19 18:07:22 +00:00
using System.Drawing ;
2014-02-26 14:11:06 +00:00
using System.Drawing.Imaging ;
2009-04-19 18:07:22 +00:00
using System.Globalization ;
2014-02-26 14:11:06 +00:00
using System.IO ;
using System.Reflection ;
using System.Runtime.InteropServices ;
2009-04-19 18:07:22 +00:00
using System.Windows.Forms ;
2014-02-26 14:11:06 +00:00
2009-04-19 18:07:22 +00:00
using CodeImp.DoomBuilder.Actions ;
2014-02-26 14:11:06 +00:00
using CodeImp.DoomBuilder.Config ;
using CodeImp.DoomBuilder.Controls ;
using CodeImp.DoomBuilder.Data ;
2009-04-19 18:07:22 +00:00
using CodeImp.DoomBuilder.Editing ;
2015-07-30 23:48:16 +00:00
using CodeImp.DoomBuilder.GZBuilder.Data ;
2014-02-26 14:11:06 +00:00
using CodeImp.DoomBuilder.Geometry ;
using CodeImp.DoomBuilder.IO ;
2009-04-19 18:07:22 +00:00
using CodeImp.DoomBuilder.Map ;
using CodeImp.DoomBuilder.Plugins ;
using CodeImp.DoomBuilder.Properties ;
2014-02-26 14:11:06 +00:00
using CodeImp.DoomBuilder.Rendering ;
2014-01-17 14:41:38 +00:00
using CodeImp.DoomBuilder.VisualModes ;
2009-04-19 18:07:22 +00:00
#endregion
namespace CodeImp.DoomBuilder.Windows
{
public partial class MainForm : DelayedForm , IMainForm
{
#region = = = = = = = = = = = = = = = = = = Constants
2009-07-19 20:30:15 +00:00
// Recent files
2009-04-19 18:07:22 +00:00
private const int MAX_RECENT_FILES_PIXELS = 250 ;
// Status bar
2015-11-30 14:18:42 +00:00
internal const int WARNING_FLASH_COUNT = 10 ;
internal const int WARNING_FLASH_INTERVAL = 100 ;
internal const int WARNING_RESET_DELAY = 5000 ;
internal const int INFO_RESET_DELAY = 5000 ;
internal const int ACTION_FLASH_COUNT = 3 ;
internal const int ACTION_FLASH_INTERVAL = 50 ;
internal const int ACTION_RESET_DELAY = 5000 ;
2009-04-19 18:07:22 +00:00
2015-11-30 14:18:42 +00:00
internal readonly Image [ , ] STATUS_IMAGES = new Image [ , ]
2009-04-19 18:07:22 +00:00
{
// Normal versions
{
2014-02-21 14:42:12 +00:00
Resources . Status0 , Resources . Status1 ,
Resources . Status2 , Resources . Warning
2009-04-19 18:07:22 +00:00
} ,
// Flashing versions
{
2014-02-21 14:42:12 +00:00
Resources . Status10 , Resources . Status11 ,
Resources . Status12 , Resources . WarningOff
2009-04-19 18:07:22 +00:00
}
} ;
2017-01-14 23:40:19 +00:00
#endregion
2009-04-19 18:07:22 +00:00
#region = = = = = = = = = = = = = = = = = = Delegates
2013-07-19 15:30:58 +00:00
//private delegate void CallUpdateStatusIcon();
//private delegate void CallImageDataLoaded(ImageData img);
2013-03-18 13:52:27 +00:00
private delegate void CallBlink ( ) ; //mxd
2009-04-19 18:07:22 +00:00
#endregion
2013-07-08 13:13:28 +00:00
#region = = = = = = = = = = = = = = = = = = mxd . Events
public event EventHandler OnEditFormValuesChanged ; //mxd
#endregion
2009-04-19 18:07:22 +00:00
#region = = = = = = = = = = = = = = = = = = Variables
// Position/size
private bool displayresized = true ;
private bool windowactive ;
// Mouse in display
private bool mouseinside ;
// Input
private bool shift , ctrl , alt ;
private MouseButtons mousebuttons ;
private MouseInput mouseinput ;
private bool mouseexclusive ;
private int mouseexclusivebreaklevel ;
// Last info on panels
private object lastinfoobject ;
// Recent files
private ToolStripMenuItem [ ] recentitems ;
// View modes
private ToolStripButton [ ] viewmodesbuttons ;
private ToolStripMenuItem [ ] viewmodesitems ;
2016-06-02 09:55:01 +00:00
//mxd. Geometry merge modes
private ToolStripButton [ ] geomergemodesbuttons ;
private ToolStripMenuItem [ ] geomergemodesitems ;
2009-04-19 18:07:22 +00:00
// Edit modes
private List < ToolStripItem > editmodeitems ;
// Toolbar
2010-08-22 20:56:52 +00:00
private List < PluginToolbarButton > pluginbuttons ;
2009-04-19 18:07:22 +00:00
private EventHandler buttonvisiblechangedhandler ;
2010-08-22 20:56:52 +00:00
private bool preventupdateseperators ;
2009-04-19 18:07:22 +00:00
private bool updatingfilters ;
2013-04-01 11:06:01 +00:00
private bool toolbarContextMenuShiftPressed ; //mxd
2009-04-19 18:07:22 +00:00
// Statusbar
private StatusInfo status ;
private int statusflashcount ;
private bool statusflashicon ;
// Properties
private IntPtr windowptr ;
// Processing
private int processingcount ;
2016-03-14 00:01:21 +00:00
private long lastupdatetime ;
2009-07-21 18:48:00 +00:00
// Updating
private int lockupdatecount ;
2015-09-25 13:20:53 +00:00
private bool mapchanged ; //mxd
2012-06-01 10:17:47 +00:00
2014-01-08 09:46:57 +00:00
//mxd. Hints
private Docker hintsDocker ;
private HintsPanel hintsPanel ;
2013-09-11 09:47:53 +00:00
//mxd
2013-03-18 13:52:27 +00:00
private System . Timers . Timer blinkTimer ;
2014-01-11 10:23:42 +00:00
private bool editformopen ;
2016-03-30 23:25:03 +00:00
//mxd. Misc drawing
private Graphics graphics ;
2017-02-07 18:02:31 +00:00
#endregion
2009-04-19 18:07:22 +00:00
2017-02-07 18:02:31 +00:00
#region = = = = = = = = = = = = = = = = = = Properties
2017-02-07 04:53:00 +00:00
2017-02-07 18:02:31 +00:00
public bool ShiftState { get { return shift ; } }
2009-04-19 18:07:22 +00:00
public bool CtrlState { get { return ctrl ; } }
public bool AltState { get { return alt ; } }
2013-03-18 13:52:27 +00:00
new public MouseButtons MouseButtons { get { return mousebuttons ; } }
2009-04-19 18:07:22 +00:00
public bool MouseInDisplay { get { return mouseinside ; } }
2009-08-21 14:11:18 +00:00
public RenderTargetControl Display { get { return display ; } }
2009-04-19 18:07:22 +00:00
public bool SnapToGrid { get { return buttonsnaptogrid . Checked ; } }
public bool AutoMerge { get { return buttonautomerge . Checked ; } }
public bool MouseExclusive { get { return mouseexclusive ; } }
new public IntPtr Handle { get { return windowptr ; } }
2009-07-09 22:43:39 +00:00
public bool IsInfoPanelExpanded { get { return ( panelinfo . Height = = heightpanel1 . Height ) ; } }
2014-10-13 22:01:17 +00:00
public string ActiveDockerTabName { get { return dockerspanel . IsCollpased ? "None" : dockerspanel . SelectedTabName ; } }
2009-04-19 18:07:22 +00:00
public bool IsActiveWindow { get { return windowactive ; } }
public StatusInfo Status { get { return status ; } }
2015-03-30 11:22:46 +00:00
public static Size ScaledIconSize = new Size ( 16 , 16 ) ; //mxd
public static SizeF DPIScaler = new SizeF ( 1.0f , 1.0f ) ; //mxd
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Constructor / Disposer
// Constructor
internal MainForm ( )
{
2016-04-06 11:44:38 +00:00
// Fetch pointer
windowptr = base . Handle ;
//mxd. Graphics
graphics = Graphics . FromHwndInternal ( windowptr ) ;
2015-03-30 11:22:46 +00:00
//mxd. Set DPI-aware icon size
2016-04-06 11:44:38 +00:00
DPIScaler = new SizeF ( graphics . DpiX / 96 , graphics . DpiY / 96 ) ;
2015-03-30 11:22:46 +00:00
2016-04-06 11:44:38 +00:00
if ( DPIScaler . Width ! = 1.0f | | DPIScaler . Height ! = 1.0f )
{
ScaledIconSize . Width = ( int ) Math . Round ( ScaledIconSize . Width * DPIScaler . Width ) ;
ScaledIconSize . Height = ( int ) Math . Round ( ScaledIconSize . Height * DPIScaler . Height ) ;
2015-03-30 11:22:46 +00:00
}
2009-04-19 18:07:22 +00:00
// Setup controls
InitializeComponent ( ) ;
2015-03-30 11:22:46 +00:00
//mxd. Resize status labels
if ( DPIScaler . Width ! = 1.0f )
{
gridlabel . Width = ( int ) Math . Round ( gridlabel . Width * DPIScaler . Width ) ;
zoomlabel . Width = ( int ) Math . Round ( zoomlabel . Width * DPIScaler . Width ) ;
xposlabel . Width = ( int ) Math . Round ( xposlabel . Width * DPIScaler . Width ) ;
yposlabel . Width = ( int ) Math . Round ( yposlabel . Width * DPIScaler . Width ) ;
warnsLabel . Width = ( int ) Math . Round ( warnsLabel . Width * DPIScaler . Width ) ;
}
2010-08-22 20:56:52 +00:00
pluginbuttons = new List < PluginToolbarButton > ( ) ;
2009-04-19 18:07:22 +00:00
editmodeitems = new List < ToolStripItem > ( ) ;
labelcollapsedinfo . Text = "" ;
2015-03-05 23:19:10 +00:00
display . Dock = DockStyle . Fill ;
2009-04-19 18:07:22 +00:00
// Make array for view modes
viewmodesbuttons = new ToolStripButton [ Renderer2D . NUM_VIEW_MODES ] ;
viewmodesbuttons [ ( int ) ViewMode . Normal ] = buttonviewnormal ;
viewmodesbuttons [ ( int ) ViewMode . Brightness ] = buttonviewbrightness ;
viewmodesbuttons [ ( int ) ViewMode . FloorTextures ] = buttonviewfloors ;
viewmodesbuttons [ ( int ) ViewMode . CeilingTextures ] = buttonviewceilings ;
viewmodesitems = new ToolStripMenuItem [ Renderer2D . NUM_VIEW_MODES ] ;
viewmodesitems [ ( int ) ViewMode . Normal ] = itemviewnormal ;
viewmodesitems [ ( int ) ViewMode . Brightness ] = itemviewbrightness ;
viewmodesitems [ ( int ) ViewMode . FloorTextures ] = itemviewfloors ;
viewmodesitems [ ( int ) ViewMode . CeilingTextures ] = itemviewceilings ;
2016-06-02 09:55:01 +00:00
//mxd. Make arrays for geometry merge modes
int numgeomodes = Enum . GetValues ( typeof ( MergeGeometryMode ) ) . Length ;
geomergemodesbuttons = new ToolStripButton [ numgeomodes ] ;
geomergemodesbuttons [ ( int ) MergeGeometryMode . CLASSIC ] = buttonmergegeoclassic ;
geomergemodesbuttons [ ( int ) MergeGeometryMode . MERGE ] = buttonmergegeo ;
geomergemodesbuttons [ ( int ) MergeGeometryMode . REPLACE ] = buttonplacegeo ;
geomergemodesitems = new ToolStripMenuItem [ numgeomodes ] ;
geomergemodesitems [ ( int ) MergeGeometryMode . CLASSIC ] = itemmergegeoclassic ;
geomergemodesitems [ ( int ) MergeGeometryMode . MERGE ] = itemmergegeo ;
geomergemodesitems [ ( int ) MergeGeometryMode . REPLACE ] = itemreplacegeo ;
2009-04-19 18:07:22 +00:00
// Visual Studio IDE doesn't let me set these in the designer :(
buttonzoom . Font = menufile . Font ;
buttonzoom . DropDownDirection = ToolStripDropDownDirection . AboveLeft ;
buttongrid . Font = menufile . Font ;
buttongrid . DropDownDirection = ToolStripDropDownDirection . AboveLeft ;
// Event handlers
2014-02-19 09:55:05 +00:00
buttonvisiblechangedhandler = ToolbarButtonVisibleChanged ;
2013-03-18 13:52:27 +00:00
//mxd
2014-02-19 09:55:05 +00:00
display . OnKeyReleased + = display_OnKeyReleased ;
toolbarContextMenu . KeyDown + = toolbarContextMenu_KeyDown ;
toolbarContextMenu . KeyUp + = toolbarContextMenu_KeyUp ;
2015-07-30 23:48:16 +00:00
linedefcolorpresets . DropDown . MouseLeave + = linedefcolorpresets_MouseLeave ;
2016-09-06 19:14:49 +00:00
this . MouseCaptureChanged + = MainForm_MouseCaptureChanged ;
2009-04-19 18:07:22 +00:00
// Apply shortcut keys
ApplyShortcutKeys ( ) ;
// Make recent items list
CreateRecentFiles ( ) ;
// Show splash
ShowSplashDisplay ( ) ;
2013-11-29 12:24:47 +00:00
//mxd
2014-02-19 09:55:05 +00:00
blinkTimer = new System . Timers . Timer { Interval = 500 } ;
2013-11-29 12:24:47 +00:00
blinkTimer . Elapsed + = blinkTimer_Elapsed ;
2014-01-08 09:46:57 +00:00
2014-11-13 09:43:39 +00:00
//mxd. Debug Console
#if DEBUG
modename . Visible = false ;
#else
console . Visible = false ;
#endif
2014-01-08 09:46:57 +00:00
//mxd. Hints
hintsPanel = new HintsPanel ( ) ;
hintsDocker = new Docker ( "hints" , "Help" , hintsPanel ) ;
2019-12-31 12:57:29 +00:00
KeyPreview = true ;
PreviewKeyDown + = new PreviewKeyDownEventHandler ( MainForm_PreviewKeyDown ) ;
2009-04-19 18:07:22 +00:00
}
#endregion
#region = = = = = = = = = = = = = = = = = = General
// Editing mode changed!
internal void EditModeChanged ( )
{
// Check appropriate button on interface
// And show the mode name
if ( General . Editing . Mode ! = null )
{
General . MainWindow . CheckEditModeButton ( General . Editing . Mode . EditModeButtonName ) ;
2021-03-21 20:19:14 +00:00
General . MainWindow . DisplayModeName ( General . Editing . Mode . Attributes . DisplayName + ( General . Editing . Mode . Attributes . IsDeprecated ? " (deprecated)" : "" ) ) ;
2009-04-19 18:07:22 +00:00
}
else
{
General . MainWindow . CheckEditModeButton ( "" ) ;
General . MainWindow . DisplayModeName ( "" ) ;
}
// View mode only matters in classic editing modes
2016-06-02 09:55:01 +00:00
bool isclassicmode = ( General . Editing . Mode is ClassicMode ) ;
2009-04-19 18:07:22 +00:00
for ( int i = 0 ; i < Renderer2D . NUM_VIEW_MODES ; i + + )
{
2016-06-02 09:55:01 +00:00
viewmodesitems [ i ] . Enabled = isclassicmode ;
viewmodesbuttons [ i ] . Enabled = isclassicmode ;
}
//mxd. Merge geometry mode only matters in classic editing modes
for ( int i = 0 ; i < geomergemodesbuttons . Length ; i + + )
{
geomergemodesbuttons [ i ] . Enabled = isclassicmode ;
geomergemodesitems [ i ] . Enabled = isclassicmode ;
2009-04-19 18:07:22 +00:00
}
2011-12-03 14:49:53 +00:00
UpdateEditMenu ( ) ;
UpdatePrefabsMenu ( ) ;
2009-04-19 18:07:22 +00:00
}
// This makes a beep sound
public void MessageBeep ( MessageBeepType type )
{
General . MessageBeep ( type ) ;
}
2009-07-19 20:30:15 +00:00
// This sets up the interface
internal void SetupInterface ( )
{
2009-07-20 15:16:40 +00:00
// Setup docker
2015-03-05 23:19:10 +00:00
if ( General . Settings . DockersPosition ! = 2 & & General . Map ! = null )
2009-07-19 20:30:15 +00:00
{
2009-07-21 18:48:00 +00:00
LockUpdate ( ) ;
dockerspanel . Visible = true ;
dockersspace . Visible = true ;
// We can't place the docker easily when collapsed
dockerspanel . Expand ( ) ;
// Setup docker width
if ( General . Settings . DockersWidth < dockerspanel . GetCollapsedWidth ( ) )
General . Settings . DockersWidth = dockerspanel . GetCollapsedWidth ( ) ;
// Determine fixed space required
if ( General . Settings . CollapseDockers )
dockersspace . Width = dockerspanel . GetCollapsedWidth ( ) ;
else
dockersspace . Width = General . Settings . DockersWidth ;
// Setup docker
2015-03-05 23:19:10 +00:00
int targetindex = this . Controls . IndexOf ( display ) + 1 ; //mxd
2009-07-21 18:48:00 +00:00
if ( General . Settings . DockersPosition = = 0 )
{
2014-02-26 14:11:06 +00:00
modestoolbar . Dock = DockStyle . Right ; //mxd
2009-07-21 18:48:00 +00:00
dockersspace . Dock = DockStyle . Left ;
2015-03-05 23:19:10 +00:00
AdjustDockersSpace ( targetindex ) ; //mxd
2009-07-21 18:48:00 +00:00
dockerspanel . Setup ( false ) ;
dockerspanel . Location = dockersspace . Location ;
dockerspanel . Anchor = AnchorStyles . Left | AnchorStyles . Top | AnchorStyles . Bottom ;
}
else
{
2014-02-26 14:11:06 +00:00
modestoolbar . Dock = DockStyle . Left ; //mxd
2009-07-21 18:48:00 +00:00
dockersspace . Dock = DockStyle . Right ;
2015-03-05 23:19:10 +00:00
AdjustDockersSpace ( targetindex ) ; //mxd
2009-07-21 18:48:00 +00:00
dockerspanel . Setup ( true ) ;
dockerspanel . Location = new Point ( dockersspace . Right - General . Settings . DockersWidth , dockersspace . Top ) ;
dockerspanel . Anchor = AnchorStyles . Right | AnchorStyles . Top | AnchorStyles . Bottom ;
}
dockerspanel . Width = General . Settings . DockersWidth ;
dockerspanel . Height = dockersspace . Height ;
dockerspanel . BringToFront ( ) ;
2015-03-05 23:19:10 +00:00
if ( General . Settings . CollapseDockers ) dockerspanel . Collapse ( ) ;
2009-07-21 18:48:00 +00:00
UnlockUpdate ( ) ;
2017-02-07 18:02:31 +00:00
}
2009-07-20 15:16:40 +00:00
else
{
2009-07-21 18:48:00 +00:00
dockerspanel . Visible = false ;
dockersspace . Visible = false ;
2015-03-05 23:19:10 +00:00
modestoolbar . Dock = DockStyle . Left ; //mxd
}
}
//mxd. dockersspace display index gets messed up while re-docking. This fixes it...
private void AdjustDockersSpace ( int targetindex )
{
while ( this . Controls . IndexOf ( dockersspace ) ! = targetindex )
{
this . Controls . SetChildIndex ( dockersspace , targetindex ) ;
2009-07-20 15:16:40 +00:00
}
2009-07-19 20:30:15 +00:00
}
2009-04-19 18:07:22 +00:00
// This updates all menus for the current status
internal void UpdateInterface ( )
{
2015-09-25 13:20:53 +00:00
//mxd. Update title
UpdateTitle ( ) ;
2009-04-26 21:38:45 +00:00
2009-04-19 18:07:22 +00:00
// Update the status bar
UpdateStatusbar ( ) ;
// Update menus and toolbar icons
UpdateFileMenu ( ) ;
UpdateEditMenu ( ) ;
UpdateViewMenu ( ) ;
UpdateModeMenu ( ) ;
UpdatePrefabsMenu ( ) ;
UpdateToolsMenu ( ) ;
UpdateToolbar ( ) ;
2017-02-07 18:02:31 +00:00
UpdateSkills ( ) ;
2009-04-19 18:07:22 +00:00
UpdateHelpMenu ( ) ;
}
2015-09-25 13:20:53 +00:00
//mxd
private void UpdateTitle ( )
{
2019-01-14 18:07:08 +00:00
string programname = this . Text = Application . ProductName + " R" + General . ThisAssembly . GetName ( ) . Version . Revision ;
2019-12-24 07:12:45 +00:00
if ( Environment . Is64BitProcess )
programname + = " (64-bit)" ;
else programname + = " (32-bit)" ;
2017-01-14 23:14:15 +00:00
2019-01-14 18:07:08 +00:00
// Map opened?
if ( General . Map ! = null )
2015-09-25 13:20:53 +00:00
{
2016-01-11 13:00:52 +00:00
// Get nice name
string maptitle = ( ! string . IsNullOrEmpty ( General . Map . Data . MapInfo . Title ) ? ": " + General . Map . Data . MapInfo . Title : "" ) ;
2015-09-25 13:20:53 +00:00
// Show map name and filename in caption
2017-01-14 23:14:15 +00:00
this . Text = ( mapchanged ? "\u25CF " : "" ) + General . Map . FileTitle + " (" + General . Map . Options . CurrentName + maptitle + ") - " + programname ;
2015-09-25 13:20:53 +00:00
}
else
{
2019-01-14 18:07:08 +00:00
// Show normal caption
this . Text = programname ;
}
2015-09-25 13:20:53 +00:00
}
2009-04-19 18:07:22 +00:00
// Generic event that invokes the tagged action
public void InvokeTaggedAction ( object sender , EventArgs e )
{
this . Update ( ) ;
if ( sender is ToolStripItem )
2016-03-18 12:52:12 +00:00
General . Actions . InvokeAction ( ( ( ToolStripItem ) sender ) . Tag . ToString ( ) ) ;
2009-04-19 18:07:22 +00:00
else if ( sender is Control )
2016-03-18 12:52:12 +00:00
General . Actions . InvokeAction ( ( ( Control ) sender ) . Tag . ToString ( ) ) ;
2009-04-19 18:07:22 +00:00
else
General . Fail ( "InvokeTaggedAction used on an unexpected control." ) ;
this . Update ( ) ;
}
#endregion
#region = = = = = = = = = = = = = = = = = = Window
2009-07-21 18:48:00 +00:00
// This locks the window for updating
internal void LockUpdate ( )
{
lockupdatecount + + ;
if ( lockupdatecount = = 1 ) General . LockWindowUpdate ( this . Handle ) ;
}
// This unlocks for updating
internal void UnlockUpdate ( )
{
lockupdatecount - - ;
if ( lockupdatecount = = 0 ) General . LockWindowUpdate ( IntPtr . Zero ) ;
if ( lockupdatecount < 0 ) lockupdatecount = 0 ;
}
// This unlocks for updating
2013-12-10 12:19:27 +00:00
/ * internal void ForceUnlockUpdate ( )
2009-07-21 18:48:00 +00:00
{
if ( lockupdatecount > 0 ) General . LockWindowUpdate ( IntPtr . Zero ) ;
lockupdatecount = 0 ;
2013-12-10 12:19:27 +00:00
} * /
2015-09-25 13:20:53 +00:00
//mxd
internal void UpdateMapChangedStatus ( )
{
if ( General . Map = = null | | General . Map . IsChanged = = mapchanged ) return ;
mapchanged = General . Map . IsChanged ;
UpdateTitle ( ) ;
}
2009-07-21 18:48:00 +00:00
2009-04-19 18:07:22 +00:00
// This sets the focus on the display for correct key input
public bool FocusDisplay ( )
{
return display . Focus ( ) ;
}
// Window is first shown
private void MainForm_Shown ( object sender , EventArgs e )
{
2016-01-15 18:20:47 +00:00
// Perform auto map loading action when the window is not delayed
2009-04-19 18:07:22 +00:00
if ( ! General . DelayMainWindow ) PerformAutoMapLoading ( ) ;
}
// Auto map loading that must be done when the window is first shown after loading
// but also before the window is shown when the -delaywindow parameter is given
internal void PerformAutoMapLoading ( )
{
// Check if the command line arguments tell us to load something
if ( General . AutoLoadFile ! = null )
{
bool showdialog = false ;
MapOptions options = new MapOptions ( ) ;
// Any of the options already given?
if ( General . AutoLoadMap ! = null )
{
2014-03-20 13:04:28 +00:00
Configuration mapsettings ;
2009-04-19 18:07:22 +00:00
// Try to find existing options in the settings file
string dbsfile = General . AutoLoadFile . Substring ( 0 , General . AutoLoadFile . Length - 4 ) + ".dbs" ;
if ( File . Exists ( dbsfile ) )
try { mapsettings = new Configuration ( dbsfile , true ) ; }
catch ( Exception ) { mapsettings = new Configuration ( true ) ; }
else
mapsettings = new Configuration ( true ) ;
2015-02-19 13:00:19 +00:00
//mxd. Get proper configuration file
bool longtexturenamessupported = false ;
string configfile = General . AutoLoadConfig ;
if ( string . IsNullOrEmpty ( configfile ) ) configfile = mapsettings . ReadSetting ( "gameconfig" , "" ) ;
if ( configfile . Trim ( ) . Length = = 0 )
{
showdialog = true ;
}
else
{
2016-01-15 18:20:47 +00:00
// Get if long texture names are supported from the game configuration
ConfigurationInfo configinfo = General . GetConfigurationInfo ( configfile ) ;
longtexturenamessupported = configinfo . Configuration . ReadSetting ( "longtexturenames" , false ) ;
2015-02-19 13:00:19 +00:00
}
2009-04-19 18:07:22 +00:00
// Set map name and other options
2015-02-19 13:00:19 +00:00
options = new MapOptions ( mapsettings , General . AutoLoadMap , longtexturenamessupported ) ;
2009-04-19 18:07:22 +00:00
2011-07-26 20:06:38 +00:00
// Set resource data locations
options . CopyResources ( General . AutoLoadResources ) ;
// Set strict patches
options . StrictPatches = General . AutoLoadStrictPatches ;
2009-04-19 18:07:22 +00:00
// Set configuration file (constructor already does this, but we want this info from the cmd args if possible)
2015-02-19 13:00:19 +00:00
options . ConfigFile = configfile ;
2009-04-19 18:07:22 +00:00
}
else
{
// No options given
showdialog = true ;
}
// Show open map dialog?
if ( showdialog )
{
// Show open dialog
2014-03-20 13:04:28 +00:00
General . OpenMapFile ( General . AutoLoadFile , null ) ;
2009-04-19 18:07:22 +00:00
}
else
{
// Open with options
General . OpenMapFileWithOptions ( General . AutoLoadFile , options ) ;
}
}
}
// Window is loaded
private void MainForm_Load ( object sender , EventArgs e )
{
2013-12-20 11:40:33 +00:00
//mxd. Enable drag and drop
this . AllowDrop = true ;
this . DragEnter + = OnDragEnter ;
this . DragDrop + = OnDragDrop ;
2009-04-19 18:07:22 +00:00
// Info panel state?
2016-09-10 11:24:03 +00:00
bool expandedpanel = General . Settings . ReadSetting ( "windows." + configname + ".expandedinfopanel" , true ) ;
2009-04-19 18:07:22 +00:00
if ( expandedpanel ! = IsInfoPanelExpanded ) ToggleInfoPanel ( ) ;
}
// Window receives focus
private void MainForm_Activated ( object sender , EventArgs e )
{
windowactive = true ;
2009-04-26 21:38:45 +00:00
2015-03-05 23:19:10 +00:00
//UpdateInterface();
2009-04-19 18:07:22 +00:00
ResumeExclusiveMouseInput ( ) ;
2009-05-05 19:12:36 +00:00
ReleaseAllKeys ( ) ;
FocusDisplay ( ) ;
2009-04-19 18:07:22 +00:00
}
// Window loses focus
private void MainForm_Deactivate ( object sender , EventArgs e )
{
windowactive = false ;
BreakExclusiveMouseInput ( ) ;
2009-05-05 19:12:36 +00:00
ReleaseAllKeys ( ) ;
2009-04-19 18:07:22 +00:00
}
2016-09-06 19:14:49 +00:00
//mxd. Looks like in some cases StartMouseExclusive is called before app aquires the mouse
// which results in setting Cursor.Clip not taking effect.
private void MainForm_MouseCaptureChanged ( object sender , EventArgs e )
{
if ( mouseexclusive & & windowactive & & mouseinside & & Cursor . Clip ! = display . RectangleToScreen ( display . ClientRectangle ) )
Cursor . Clip = display . RectangleToScreen ( display . ClientRectangle ) ;
}
2009-04-19 18:07:22 +00:00
// Window is being closed
2015-04-16 13:03:12 +00:00
protected override void OnFormClosing ( FormClosingEventArgs e )
2009-04-19 18:07:22 +00:00
{
2015-04-16 13:03:12 +00:00
base . OnFormClosing ( e ) ;
if ( e . CloseReason = = CloseReason . ApplicationExitCall ) return ;
// Close the map
if ( General . CloseMap ( ) )
2009-04-19 18:07:22 +00:00
{
2015-04-16 13:03:12 +00:00
General . WriteLogLine ( "Closing main interface window..." ) ;
2009-04-19 18:07:22 +00:00
2015-04-16 13:03:12 +00:00
// Stop timers
statusflasher . Stop ( ) ;
statusresetter . Stop ( ) ;
blinkTimer . Stop ( ) ; //mxd
2009-04-19 18:07:22 +00:00
2015-04-16 13:03:12 +00:00
// Stop exclusive mode, if any is active
StopExclusiveMouseInput ( ) ;
StopProcessing ( ) ;
2009-04-19 18:07:22 +00:00
2015-04-16 13:03:12 +00:00
// Unbind methods
General . Actions . UnbindMethods ( this ) ;
// Determine window state to save
2016-09-10 11:24:03 +00:00
General . Settings . WriteSetting ( "windows." + configname + ".expandedinfopanel" , IsInfoPanelExpanded ) ;
2015-04-16 13:03:12 +00:00
// Save recent files
SaveRecentFiles ( ) ;
// Terminate the program
General . Terminate ( true ) ;
}
else
{
// Cancel the close
e . Cancel = true ;
2009-04-19 18:07:22 +00:00
}
}
2013-12-20 11:40:33 +00:00
//mxd
2014-12-03 23:15:26 +00:00
private void OnDragEnter ( object sender , DragEventArgs e )
{
if ( e . Data . GetDataPresent ( DataFormats . FileDrop ) )
{
2013-12-20 11:40:33 +00:00
e . Effect = DragDropEffects . Copy ;
2014-12-03 23:15:26 +00:00
}
else
{
2013-12-20 11:40:33 +00:00
e . Effect = DragDropEffects . None ;
}
}
//mxd
2016-03-14 21:53:53 +00:00
private void OnDragDrop ( object sender , DragEventArgs e )
2014-12-03 23:15:26 +00:00
{
2015-12-28 15:01:53 +00:00
if ( e . Data . GetDataPresent ( DataFormats . FileDrop ) )
2014-12-03 23:15:26 +00:00
{
2016-03-14 21:53:53 +00:00
string [ ] filepaths = ( string [ ] ) e . Data . GetData ( DataFormats . FileDrop ) ;
if ( filepaths . Length ! = 1 )
2014-12-03 23:15:26 +00:00
{
2013-12-20 11:40:33 +00:00
General . Interface . DisplayStatus ( StatusType . Warning , "Cannot open multiple files at once!" ) ;
return ;
}
2016-03-14 21:53:53 +00:00
if ( ! File . Exists ( filepaths [ 0 ] ) )
2014-12-03 23:15:26 +00:00
{
2016-03-14 21:53:53 +00:00
General . Interface . DisplayStatus ( StatusType . Warning , "Cannot open \"" + filepaths [ 0 ] + "\": file does not exist!" ) ;
2013-12-20 11:40:33 +00:00
return ;
}
2016-03-14 21:53:53 +00:00
string ext = Path . GetExtension ( filepaths [ 0 ] ) ;
2014-12-03 23:15:26 +00:00
if ( string . IsNullOrEmpty ( ext ) | | ext . ToLower ( ) ! = ".wad" )
{
2016-03-14 21:53:53 +00:00
General . Interface . DisplayStatus ( StatusType . Warning , "Cannot open \"" + filepaths [ 0 ] + "\": only WAD files can be loaded this way!" ) ;
2013-12-20 11:40:33 +00:00
return ;
}
2016-03-14 21:53:53 +00:00
// If we call General.OpenMapFile here, it will lock the source window in the waiting state untill OpenMapOptionsForm is closed.
Timer t = new Timer { Tag = filepaths [ 0 ] , Interval = 10 } ;
t . Tick + = OnDragDropTimerTick ;
t . Start ( ) ;
}
}
private void OnDragDropTimerTick ( object sender , EventArgs e )
{
Timer t = sender as Timer ;
if ( t ! = null )
{
t . Stop ( ) ;
string targetwad = t . Tag . ToString ( ) ;
2013-12-20 11:40:33 +00:00
this . Update ( ) ; // Update main window
2016-03-14 21:53:53 +00:00
General . OpenMapFile ( targetwad , null ) ;
2013-12-20 11:40:33 +00:00
UpdateGZDoomPanel ( ) ;
}
}
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Statusbar
// This updates the status bar
private void UpdateStatusbar ( )
{
// Map open?
if ( General . Map ! = null )
{
// Enable items
xposlabel . Enabled = true ;
yposlabel . Enabled = true ;
poscommalabel . Enabled = true ;
zoomlabel . Enabled = true ;
buttonzoom . Enabled = true ;
gridlabel . Enabled = true ;
2016-12-27 13:59:20 +00:00
itemgrid05 . Visible = General . Map . UDMF ; //mxd
itemgrid025 . Visible = General . Map . UDMF ; //mxd
itemgrid0125 . Visible = General . Map . UDMF ; //mxd
2009-04-19 18:07:22 +00:00
buttongrid . Enabled = true ;
configlabel . Text = General . Map . Config . Name ;
2016-12-27 13:59:20 +00:00
//mxd. Raise grid size to 1 if it was lower and the map isn't in UDMF
2017-01-06 10:01:59 +00:00
if ( ! General . Map . UDMF & & General . Map . Grid . GridSizeF < GridSetup . MINIMUM_GRID_SIZE )
2016-12-27 13:59:20 +00:00
General . Map . Grid . SetGridSize ( GridSetup . MINIMUM_GRID_SIZE ) ;
2009-04-19 18:07:22 +00:00
}
else
{
// Disable items
xposlabel . Text = "--" ;
yposlabel . Text = "--" ;
xposlabel . Enabled = false ;
yposlabel . Enabled = false ;
poscommalabel . Enabled = false ;
zoomlabel . Enabled = false ;
buttonzoom . Enabled = false ;
gridlabel . Enabled = false ;
buttongrid . Enabled = false ;
configlabel . Text = "" ;
}
UpdateStatusIcon ( ) ;
}
// This flashes the status icon
private void statusflasher_Tick ( object sender , EventArgs e )
{
statusflashicon = ! statusflashicon ;
UpdateStatusIcon ( ) ;
statusflashcount - - ;
if ( statusflashcount = = 0 ) statusflasher . Stop ( ) ;
}
// This resets the status to ready
private void statusresetter_Tick ( object sender , EventArgs e )
{
DisplayReady ( ) ;
}
// This changes status text
public void DisplayStatus ( StatusType type , string message ) { DisplayStatus ( new StatusInfo ( type , message ) ) ; }
public void DisplayStatus ( StatusInfo newstatus )
{
// Stop timers
2015-09-16 12:10:43 +00:00
if ( ! newstatus . displayed )
2009-04-19 18:07:22 +00:00
{
statusresetter . Stop ( ) ;
statusflasher . Stop ( ) ;
statusflashicon = false ;
}
// Determine what to do specifically for this status type
switch ( newstatus . type )
{
// Shows information without flashing the icon.
2015-09-16 12:10:43 +00:00
case StatusType . Ready : //mxd
case StatusType . Selection : //mxd
2009-04-19 18:07:22 +00:00
case StatusType . Info :
if ( ! newstatus . displayed )
{
statusresetter . Interval = INFO_RESET_DELAY ;
statusresetter . Start ( ) ;
}
break ;
// Shows action information and flashes up the status icon once.
case StatusType . Action :
if ( ! newstatus . displayed )
{
statusflashicon = true ;
statusflasher . Interval = ACTION_FLASH_INTERVAL ;
statusflashcount = ACTION_FLASH_COUNT ;
statusflasher . Start ( ) ;
statusresetter . Interval = ACTION_RESET_DELAY ;
statusresetter . Start ( ) ;
}
break ;
// Shows a warning, makes a warning sound and flashes a warning icon.
case StatusType . Warning :
if ( ! newstatus . displayed )
{
MessageBeep ( MessageBeepType . Warning ) ;
statusflasher . Interval = WARNING_FLASH_INTERVAL ;
statusflashcount = WARNING_FLASH_COUNT ;
statusflasher . Start ( ) ;
statusresetter . Interval = WARNING_RESET_DELAY ;
statusresetter . Start ( ) ;
}
break ;
}
// Update status description
status = newstatus ;
status . displayed = true ;
2015-09-16 12:10:43 +00:00
statuslabel . Text = status . ToString ( ) ; //mxd. message -> ToString()
2009-04-19 18:07:22 +00:00
// Update icon as well
UpdateStatusIcon ( ) ;
// Refresh
statusbar . Invalidate ( ) ;
2017-02-08 12:18:01 +00:00
//this.Update(); // ano - this is unneeded afaict and slow
2009-04-19 18:07:22 +00:00
}
// This changes status text to Ready
public void DisplayReady ( )
{
DisplayStatus ( StatusType . Ready , null ) ;
}
// This updates the status icon
2015-09-08 14:54:53 +00:00
private void UpdateStatusIcon ( )
2009-04-19 18:07:22 +00:00
{
int statusicon = 0 ;
int statusflashindex = statusflashicon ? 1 : 0 ;
// Loading icon?
if ( ( General . Map ! = null ) & & ( General . Map . Data ! = null ) & & General . Map . Data . IsLoading )
statusicon = 1 ;
// Status type
switch ( status . type )
{
case StatusType . Ready :
case StatusType . Info :
case StatusType . Action :
2013-07-09 11:29:10 +00:00
case StatusType . Selection : //mxd
2009-04-19 18:07:22 +00:00
statuslabel . Image = STATUS_IMAGES [ statusflashindex , statusicon ] ;
break ;
case StatusType . Busy :
statuslabel . Image = STATUS_IMAGES [ statusflashindex , 2 ] ;
break ;
case StatusType . Warning :
statuslabel . Image = STATUS_IMAGES [ statusflashindex , 3 ] ;
break ;
}
}
// This changes coordinates display
2016-06-03 20:22:07 +00:00
public void UpdateCoordinates ( Vector2D coords ) { UpdateCoordinates ( coords , false ) ; } //mxd
public void UpdateCoordinates ( Vector2D coords , bool snaptogrid )
2009-04-19 18:07:22 +00:00
{
2016-06-03 20:22:07 +00:00
//mxd
if ( snaptogrid ) coords = General . Map . Grid . SnappedToGrid ( coords ) ;
2009-04-19 18:07:22 +00:00
// X position
2020-05-21 12:20:02 +00:00
xposlabel . Text = ( double . IsNaN ( coords . x ) ? "--" : coords . x . ToString ( "####0" ) ) ;
2009-04-19 18:07:22 +00:00
// Y position
2020-05-21 12:20:02 +00:00
yposlabel . Text = ( double . IsNaN ( coords . y ) ? "--" : coords . y . ToString ( "####0" ) ) ;
2009-04-19 18:07:22 +00:00
}
// This changes zoom display
internal void UpdateZoom ( float scale )
{
// Update scale label
2015-09-08 14:54:53 +00:00
zoomlabel . Text = ( float . IsNaN ( scale ) ? "--" : ( scale * 100 ) . ToString ( "##0" ) + "%" ) ;
2009-04-19 18:07:22 +00:00
}
// Zoom to a specified level
private void itemzoomto_Click ( object sender , EventArgs e )
{
// In classic mode?
2015-09-08 14:54:53 +00:00
if ( General . Map ! = null & & General . Editing . Mode is ClassicMode )
2009-04-19 18:07:22 +00:00
{
// Requested from menu?
2016-03-18 12:52:12 +00:00
ToolStripMenuItem item = sender as ToolStripMenuItem ;
if ( item ! = null )
2009-04-19 18:07:22 +00:00
{
// Get integral zoom level
2016-03-18 12:52:12 +00:00
int zoom = int . Parse ( item . Tag . ToString ( ) , CultureInfo . InvariantCulture ) ;
2009-04-19 18:07:22 +00:00
// Zoom now
2016-03-18 12:52:12 +00:00
( ( ClassicMode ) General . Editing . Mode ) . SetZoom ( zoom / 100f ) ;
2009-04-19 18:07:22 +00:00
}
}
}
// Zoom to fit in screen
private void itemzoomfittoscreen_Click ( object sender , EventArgs e )
{
// In classic mode?
2015-09-08 14:54:53 +00:00
if ( General . Map ! = null & & General . Editing . Mode is ClassicMode )
2016-03-18 12:52:12 +00:00
( ( ClassicMode ) General . Editing . Mode ) . CenterInScreen ( ) ;
2009-04-19 18:07:22 +00:00
}
// This changes grid display
2020-05-21 12:20:02 +00:00
internal void UpdateGrid ( double gridsize )
2009-04-19 18:07:22 +00:00
{
// Update grid label
2016-12-27 13:59:20 +00:00
gridlabel . Text = ( gridsize = = 0 ? "--" : gridsize + " mp" ) ;
2009-04-19 18:07:22 +00:00
}
// Set grid to a specified size
private void itemgridsize_Click ( object sender , EventArgs e )
{
if ( General . Map = = null ) return ;
// In classic mode?
if ( General . Editing . Mode is ClassicMode )
{
// Requested from menu?
2016-03-18 12:52:12 +00:00
ToolStripMenuItem item = sender as ToolStripMenuItem ;
if ( item ! = null )
2009-04-19 18:07:22 +00:00
{
2016-12-27 13:59:20 +00:00
//mxd. Get decimal zoom level
float size = float . Parse ( item . Tag . ToString ( ) , CultureInfo . InvariantCulture ) ;
2009-04-19 18:07:22 +00:00
2016-03-04 13:41:55 +00:00
//mxd. Disable automatic grid resizing
DisableDynamicGridResize ( ) ;
2009-04-19 18:07:22 +00:00
// Change grid size
General . Map . Grid . SetGridSize ( size ) ;
// Redraw display
RedrawDisplay ( ) ;
}
}
}
// Show grid setup
private void itemgridcustom_Click ( object sender , EventArgs e )
{
2015-09-08 14:54:53 +00:00
if ( General . Map ! = null ) GridSetup . ShowGridSetup ( ) ;
2009-04-19 18:07:22 +00:00
}
#endregion
#region = = = = = = = = = = = = = = = = = = Display
// This shows the splash screen on display
internal void ShowSplashDisplay ( )
{
// Change display to show splash logo
display . SetSplashLogoDisplay ( ) ;
display . Cursor = Cursors . Default ;
this . Update ( ) ;
}
// This clears the display
internal void ClearDisplay ( )
{
// Clear the display
display . SetManualRendering ( ) ;
this . Update ( ) ;
}
// This sets the display cursor
public void SetCursor ( Cursor cursor )
{
// Only when a map is open
if ( General . Map ! = null ) display . Cursor = cursor ;
}
// This redraws the display on the next paint event
public void RedrawDisplay ( )
{
if ( ( General . Map ! = null ) & & ( General . Editing . Mode ! = null ) )
{
2010-08-22 11:36:09 +00:00
General . Plugins . OnEditRedrawDisplayBegin ( ) ;
2009-04-19 18:07:22 +00:00
General . Editing . Mode . OnRedrawDisplay ( ) ;
2010-08-22 11:36:09 +00:00
General . Plugins . OnEditRedrawDisplayEnd ( ) ;
2015-01-10 11:45:25 +00:00
statistics . UpdateStatistics ( ) ; //mxd
2009-04-19 18:07:22 +00:00
}
else
{
display . Invalidate ( ) ;
}
}
// This event is called when a repaint is needed
private void display_Paint ( object sender , PaintEventArgs e )
{
if ( General . Map ! = null )
{
if ( General . Editing . Mode ! = null )
{
if ( ! displayresized ) General . Editing . Mode . OnPresentDisplay ( ) ;
}
else
{
if ( General . Colors ! = null )
e . Graphics . Clear ( Color . FromArgb ( General . Colors . Background . ToInt ( ) ) ) ;
else
2016-01-26 22:29:12 +00:00
e . Graphics . Clear ( SystemColors . ControlDarkDark ) ;
2009-04-19 18:07:22 +00:00
}
}
}
// Redraw requested
private void redrawtimer_Tick ( object sender , EventArgs e )
{
// Disable timer (only redraw once)
redrawtimer . Enabled = false ;
2014-09-17 12:46:47 +00:00
// Don't do anything when minimized (mxd)
if ( this . WindowState = = FormWindowState . Minimized ) return ;
2009-04-19 18:07:22 +00:00
// Resume control layouts
//if(displayresized) General.LockWindowUpdate(IntPtr.Zero);
// Map opened?
if ( General . Map ! = null )
{
// Display was resized?
if ( displayresized )
{
2016-01-14 22:15:54 +00:00
//mxd. Aspect ratio may've been changed
General . Map . CRenderer3D . CreateProjection ( ) ;
2009-04-19 18:07:22 +00:00
}
// This is a dirty trick to give the display a new mousemove event with correct arguments
if ( mouseinside )
{
Point mousepos = Cursor . Position ;
Cursor . Position = new Point ( mousepos . X + 1 , mousepos . Y + 1 ) ;
Cursor . Position = mousepos ;
}
// Redraw now
RedrawDisplay ( ) ;
}
// Display resize is done
displayresized = false ;
}
// Display size changes
private void display_Resize ( object sender , EventArgs e )
{
// Resizing
//if(!displayresized) General.LockWindowUpdate(display.Handle);
displayresized = true ;
2015-09-17 12:02:39 +00:00
//mxd. Separators may need updating
UpdateSeparators ( ) ;
2009-04-19 18:07:22 +00:00
// Request redraw
if ( ! redrawtimer . Enabled ) redrawtimer . Enabled = true ;
}
// This requests a delayed redraw
public void DelayedRedraw ( )
{
// Request redraw
if ( ! redrawtimer . Enabled ) redrawtimer . Enabled = true ;
}
// Mouse click
private void display_MouseClick ( object sender , MouseEventArgs e )
{
2010-08-22 11:36:09 +00:00
if ( ( General . Map ! = null ) & & ( General . Editing . Mode ! = null ) )
{
General . Plugins . OnEditMouseClick ( e ) ;
General . Editing . Mode . OnMouseClick ( e ) ;
}
2009-04-19 18:07:22 +00:00
}
// Mouse doubleclick
private void display_MouseDoubleClick ( object sender , MouseEventArgs e )
{
2010-08-22 11:36:09 +00:00
if ( ( General . Map ! = null ) & & ( General . Editing . Mode ! = null ) )
{
General . Plugins . OnEditMouseDoubleClick ( e ) ;
General . Editing . Mode . OnMouseDoubleClick ( e ) ;
}
2009-04-19 18:07:22 +00:00
}
// Mouse down
private void display_MouseDown ( object sender , MouseEventArgs e )
{
int key = 0 ;
2009-07-21 13:42:36 +00:00
LoseFocus ( this , EventArgs . Empty ) ;
2009-04-19 18:07:22 +00:00
int mod = 0 ;
if ( alt ) mod | = ( int ) Keys . Alt ;
if ( shift ) mod | = ( int ) Keys . Shift ;
if ( ctrl ) mod | = ( int ) Keys . Control ;
// Apply button
mousebuttons | = e . Button ;
// Create key
switch ( e . Button )
{
case MouseButtons . Left : key = ( int ) Keys . LButton ; break ;
case MouseButtons . Middle : key = ( int ) Keys . MButton ; break ;
case MouseButtons . Right : key = ( int ) Keys . RButton ; break ;
case MouseButtons . XButton1 : key = ( int ) Keys . XButton1 ; break ;
case MouseButtons . XButton2 : key = ( int ) Keys . XButton2 ; break ;
}
// Invoke any actions associated with this key
General . Actions . KeyPressed ( key | mod ) ;
// Invoke on editing mode
2010-08-22 11:36:09 +00:00
if ( ( General . Map ! = null ) & & ( General . Editing . Mode ! = null ) )
{
General . Plugins . OnEditMouseDown ( e ) ;
General . Editing . Mode . OnMouseDown ( e ) ;
}
2009-04-19 18:07:22 +00:00
}
// Mouse enters
private void display_MouseEnter ( object sender , EventArgs e )
{
mouseinside = true ;
2016-09-06 19:14:49 +00:00
//mxd. Skip when in mouseexclusive (e.g. Visual) mode to avoid mouse disappearing when moving it
// on top of inactive editor window while Visual mode is active
if ( ( General . Map ! = null ) & & ( mouseinput = = null ) & & ( General . Editing . Mode ! = null ) & & ! mouseexclusive )
2010-08-22 11:36:09 +00:00
{
General . Plugins . OnEditMouseEnter ( e ) ;
General . Editing . Mode . OnMouseEnter ( e ) ;
2014-01-11 10:23:42 +00:00
if ( Application . OpenForms . Count = = 1 | | editformopen ) display . Focus ( ) ; //mxd
2010-08-22 11:36:09 +00:00
}
2009-04-19 18:07:22 +00:00
}
// Mouse leaves
private void display_MouseLeave ( object sender , EventArgs e )
{
mouseinside = false ;
2010-08-22 11:36:09 +00:00
if ( ( General . Map ! = null ) & & ( mouseinput = = null ) & & ( General . Editing . Mode ! = null ) )
{
General . Plugins . OnEditMouseLeave ( e ) ;
General . Editing . Mode . OnMouseLeave ( e ) ;
}
2009-04-19 18:07:22 +00:00
}
// Mouse moves
private void display_MouseMove ( object sender , MouseEventArgs e )
{
2010-08-22 11:36:09 +00:00
if ( ( General . Map ! = null ) & & ( mouseinput = = null ) & & ( General . Editing . Mode ! = null ) )
{
General . Plugins . OnEditMouseMove ( e ) ;
General . Editing . Mode . OnMouseMove ( e ) ;
}
2009-04-19 18:07:22 +00:00
}
// Mouse up
private void display_MouseUp ( object sender , MouseEventArgs e )
{
int key = 0 ;
int mod = 0 ;
if ( alt ) mod | = ( int ) Keys . Alt ;
if ( shift ) mod | = ( int ) Keys . Shift ;
if ( ctrl ) mod | = ( int ) Keys . Control ;
// Apply button
mousebuttons & = ~ e . Button ;
// Create key
switch ( e . Button )
{
case MouseButtons . Left : key = ( int ) Keys . LButton ; break ;
case MouseButtons . Middle : key = ( int ) Keys . MButton ; break ;
case MouseButtons . Right : key = ( int ) Keys . RButton ; break ;
case MouseButtons . XButton1 : key = ( int ) Keys . XButton1 ; break ;
case MouseButtons . XButton2 : key = ( int ) Keys . XButton2 ; break ;
}
2017-02-07 18:02:31 +00:00
2009-04-19 18:07:22 +00:00
// Invoke any actions associated with this key
2017-02-07 18:02:31 +00:00
General . Actions . KeyReleased ( key | mod ) ;
2009-04-19 18:07:22 +00:00
// Invoke on editing mode
2010-08-22 11:36:09 +00:00
if ( ( General . Map ! = null ) & & ( General . Editing . Mode ! = null ) )
{
General . Plugins . OnEditMouseUp ( e ) ;
General . Editing . Mode . OnMouseUp ( e ) ;
}
2009-04-19 18:07:22 +00:00
}
#endregion
#region = = = = = = = = = = = = = = = = = = Input
// This is a tool to lock the mouse in exclusive mode
private void StartMouseExclusive ( )
{
// Not already locked?
if ( mouseinput = = null )
{
// Start special input device
mouseinput = new MouseInput ( this ) ;
// Lock and hide the mouse in window
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
Cursor . Position = display . PointToScreen ( new Point ( display . ClientSize . Width / 2 , display . ClientSize . Height / 2 ) ) ; //mxd
2009-04-19 18:07:22 +00:00
Cursor . Clip = display . RectangleToScreen ( display . ClientRectangle ) ;
Cursor . Hide ( ) ;
2020-09-13 21:43:11 +00:00
#if MONO_WINFORMS
// A beautiful transparent cursor, just for you mono!
string emptycursor =
"AAACAAEAICACAAAAAAAwAQAAFgAAACgAAAAgAAAAQAAAAAEAAQAAAAAAgAAAAAAAAAAAAAAAAgAA" +
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////////////////////" +
"////////////////////////////////////////////////////////////////////////////" +
"//////////////////////////////////////////////////////8=" ;
using ( var stream = new MemoryStream ( System . Convert . FromBase64String ( emptycursor ) ) )
{
2020-09-14 22:41:53 +00:00
var cursor = new Cursor ( stream ) ;
Cursor . Current = cursor ;
display . Cursor = cursor ;
2020-09-13 21:43:11 +00:00
}
2020-09-14 22:41:53 +00:00
Application . DoEvents ( ) ;
2020-09-13 21:43:11 +00:00
#endif
2009-04-19 18:07:22 +00:00
}
}
// This is a tool to unlock the mouse
private void StopMouseExclusive ( )
{
// Locked?
if ( mouseinput ! = null )
{
// Stop special input device
mouseinput . Dispose ( ) ;
mouseinput = null ;
// Release and show the mouse
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
Cursor . Clip = Rectangle . Empty ;
2009-04-19 18:07:22 +00:00
Cursor . Position = display . PointToScreen ( new Point ( display . ClientSize . Width / 2 , display . ClientSize . Height / 2 ) ) ;
2020-09-13 21:43:11 +00:00
#if MONO_WINFORMS
Cursor . Current = Cursors . Default ;
2020-09-14 22:41:53 +00:00
display . Cursor = Cursors . Default ;
Application . DoEvents ( ) ;
2020-09-13 21:43:11 +00:00
#endif
2020-09-14 22:41:53 +00:00
Cursor . Show ( ) ;
2009-04-19 18:07:22 +00:00
}
}
// This requests exclusive mouse input
public void StartExclusiveMouseInput ( )
{
// Only when not already in exclusive mode
if ( ! mouseexclusive )
{
General . WriteLogLine ( "Starting exclusive mouse input mode..." ) ;
// Start special input device
StartMouseExclusive ( ) ;
mouseexclusive = true ;
mouseexclusivebreaklevel = 0 ;
}
}
// This stops exclusive mouse input
public void StopExclusiveMouseInput ( )
{
// Only when in exclusive mode
if ( mouseexclusive )
{
General . WriteLogLine ( "Stopping exclusive mouse input mode..." ) ;
// Stop special input device
StopMouseExclusive ( ) ;
mouseexclusive = false ;
mouseexclusivebreaklevel = 0 ;
}
}
// This temporarely breaks exclusive mode and counts the break level
public void BreakExclusiveMouseInput ( )
{
// Only when in exclusive mode
if ( mouseexclusive )
{
// Stop special input device
StopMouseExclusive ( ) ;
// Count the break level
mouseexclusivebreaklevel + + ;
}
}
// This resumes exclusive mode from a break when all breaks have been called to resume
public void ResumeExclusiveMouseInput ( )
{
// Only when in exclusive mode
if ( mouseexclusive & & ( mouseexclusivebreaklevel > 0 ) )
{
// Decrease break level
mouseexclusivebreaklevel - - ;
// All break levels resumed? Then lock the mouse again.
if ( mouseexclusivebreaklevel = = 0 )
StartMouseExclusive ( ) ;
}
}
2009-05-05 19:12:36 +00:00
// This releases all keys
internal void ReleaseAllKeys ( )
{
General . Actions . ReleaseAllKeys ( ) ;
mousebuttons = MouseButtons . None ;
shift = false ;
ctrl = false ;
alt = false ;
}
2009-04-19 18:07:22 +00:00
// When the mouse wheel is changed
protected override void OnMouseWheel ( MouseEventArgs e )
{
int mod = 0 ;
if ( alt ) mod | = ( int ) Keys . Alt ;
if ( shift ) mod | = ( int ) Keys . Shift ;
if ( ctrl ) mod | = ( int ) Keys . Control ;
// Scrollwheel up?
if ( e . Delta > 0 )
{
// Invoke actions for scrollwheel
//for(int i = 0; i < e.Delta; i += 120)
General . Actions . KeyPressed ( ( int ) SpecialKeys . MScrollUp | mod ) ;
General . Actions . KeyReleased ( ( int ) SpecialKeys . MScrollUp | mod ) ;
}
// Scrollwheel down?
else if ( e . Delta < 0 )
{
// Invoke actions for scrollwheel
//for(int i = 0; i > e.Delta; i -= 120)
General . Actions . KeyPressed ( ( int ) SpecialKeys . MScrollDown | mod ) ;
General . Actions . KeyReleased ( ( int ) SpecialKeys . MScrollDown | mod ) ;
}
// Let the base know
base . OnMouseWheel ( e ) ;
}
2017-03-25 01:47:18 +00:00
2019-01-14 18:07:08 +00:00
// [ZZ]
private void OnMouseHWheel ( int delta )
{
int mod = 0 ;
if ( alt ) mod | = ( int ) Keys . Alt ;
if ( shift ) mod | = ( int ) Keys . Shift ;
if ( ctrl ) mod | = ( int ) Keys . Control ;
// Scrollwheel left?
if ( delta < 0 )
{
General . Actions . KeyPressed ( ( int ) SpecialKeys . MScrollLeft | mod ) ;
General . Actions . KeyReleased ( ( int ) SpecialKeys . MScrollLeft | mod ) ;
}
else if ( delta > 0 )
{
General . Actions . KeyPressed ( ( int ) SpecialKeys . MScrollRight | mod ) ;
General . Actions . KeyReleased ( ( int ) SpecialKeys . MScrollRight | mod ) ;
}
// base? what base?
}
2009-04-19 18:07:22 +00:00
2019-12-31 12:57:29 +00:00
private void MainForm_PreviewKeyDown ( object sender , PreviewKeyDownEventArgs e )
{
if ( e . KeyCode = = Keys . F10 )
e . IsInputKey = true ;
}
2009-04-19 18:07:22 +00:00
// When a key is pressed
private void MainForm_KeyDown ( object sender , KeyEventArgs e )
{
int mod = 0 ;
// Keep key modifiers
alt = e . Alt ;
shift = e . Shift ;
ctrl = e . Control ;
if ( alt ) mod | = ( int ) Keys . Alt ;
if ( shift ) mod | = ( int ) Keys . Shift ;
if ( ctrl ) mod | = ( int ) Keys . Control ;
2009-08-21 08:37:02 +00:00
2009-07-21 13:42:36 +00:00
// Don't process any keys when they are meant for other input controls
2021-03-14 15:26:09 +00:00
if ( ( e . KeyData ! = Keys . None ) & & ( ( ActiveControl = = null ) | | ( ActiveControl = = display ) ) )
2009-04-19 18:07:22 +00:00
{
// Invoke any actions associated with this key
General . Actions . UpdateModifiers ( mod ) ;
2010-08-12 21:00:54 +00:00
e . Handled = General . Actions . KeyPressed ( ( int ) e . KeyData ) ;
2009-04-19 18:07:22 +00:00
// Invoke on editing mode
2010-08-22 11:36:09 +00:00
if ( ( General . Map ! = null ) & & ( General . Editing . Mode ! = null ) )
{
General . Plugins . OnEditKeyDown ( e ) ;
General . Editing . Mode . OnKeyDown ( e ) ;
}
2010-08-12 21:00:54 +00:00
2009-07-21 13:42:36 +00:00
// Handled
2010-08-12 21:00:54 +00:00
if ( e . Handled )
e . SuppressKeyPress = true ;
2009-04-19 18:07:22 +00:00
}
2009-08-21 08:37:02 +00:00
2009-04-19 18:07:22 +00:00
// F1 pressed?
if ( ( e . KeyCode = = Keys . F1 ) & & ( e . Modifiers = = Keys . None ) )
{
// No action bound to F1?
Actions . Action [ ] f1actions = General . Actions . GetActionsByKey ( ( int ) e . KeyData ) ;
if ( f1actions . Length = = 0 )
{
// If we don't have any map open, show the Main Window help
// otherwise, give the help request to the editing mode so it
// can open the appropriate help file.
if ( ( General . Map = = null ) | | ( General . Editing . Mode = = null ) )
{
General . ShowHelp ( "introduction.html" ) ;
}
else
{
General . Editing . Mode . OnHelp ( ) ;
}
}
}
2019-12-31 12:57:29 +00:00
if ( e . KeyCode = = Keys . F10 )
{
Actions . Action [ ] f10actions = General . Actions . GetActionsByKey ( ( int ) e . KeyData ) ;
if ( f10actions . Length > 0 )
{
e . SuppressKeyPress = true ;
e . Handled = true ;
}
}
2009-04-19 18:07:22 +00:00
}
// When a key is released
private void MainForm_KeyUp ( object sender , KeyEventArgs e )
{
int mod = 0 ;
// Keep key modifiers
alt = e . Alt ;
shift = e . Shift ;
ctrl = e . Control ;
if ( alt ) mod | = ( int ) Keys . Alt ;
if ( shift ) mod | = ( int ) Keys . Shift ;
if ( ctrl ) mod | = ( int ) Keys . Control ;
2009-07-21 13:42:36 +00:00
// Don't process any keys when they are meant for other input controls
if ( ( ActiveControl = = null ) | | ( ActiveControl = = display ) )
2009-04-19 18:07:22 +00:00
{
// Invoke any actions associated with this key
General . Actions . UpdateModifiers ( mod ) ;
2010-08-12 21:00:54 +00:00
e . Handled = General . Actions . KeyReleased ( ( int ) e . KeyData ) ;
2009-04-19 18:07:22 +00:00
// Invoke on editing mode
2010-08-22 11:36:09 +00:00
if ( ( General . Map ! = null ) & & ( General . Editing . Mode ! = null ) )
{
General . Plugins . OnEditKeyUp ( e ) ;
General . Editing . Mode . OnKeyUp ( e ) ;
}
2009-07-21 13:42:36 +00:00
// Handled
2010-08-12 21:00:54 +00:00
if ( e . Handled )
e . SuppressKeyPress = true ;
2009-04-19 18:07:22 +00:00
}
2019-12-31 13:32:57 +00:00
if ( e . KeyCode = = Keys . F10 )
{
Actions . Action [ ] f10actions = General . Actions . GetActionsByKey ( ( int ) e . KeyData ) ;
if ( f10actions . Length > 0 )
{
e . SuppressKeyPress = true ;
e . Handled = true ;
}
}
2009-04-19 18:07:22 +00:00
}
2013-03-18 13:52:27 +00:00
2013-09-11 09:47:53 +00:00
//mxd. Sometimes it's handeled by RenderTargetControl, not by MainForm leading to keys being "stuck"
2014-12-03 09:06:05 +00:00
private void display_OnKeyReleased ( object sender , KeyEventArgs e )
{
2013-09-11 09:47:53 +00:00
MainForm_KeyUp ( sender , e ) ;
}
2009-07-21 13:42:36 +00:00
// These prevent focus changes by way of TAB or Arrow keys
protected override bool IsInputChar ( char charCode ) { return false ; }
protected override bool IsInputKey ( Keys keyData ) { return false ; }
protected override bool ProcessKeyPreview ( ref Message m ) { return false ; }
protected override bool ProcessDialogKey ( Keys keyData ) { return false ; }
protected override bool ProcessCmdKey ( ref Message msg , Keys keyData ) { return false ; }
// This fixes some odd input behaviour
private void display_PreviewKeyDown ( object sender , PreviewKeyDownEventArgs e )
{
if ( ( ActiveControl = = null ) | | ( ActiveControl = = display ) )
{
LoseFocus ( this , EventArgs . Empty ) ;
KeyEventArgs ea = new KeyEventArgs ( e . KeyData ) ;
MainForm_KeyDown ( sender , ea ) ;
}
}
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Toolbar
// This updates the skills list
2017-02-07 18:02:31 +00:00
private void UpdateSkills ( )
2009-04-19 18:07:22 +00:00
{
2017-02-07 18:02:31 +00:00
// Clear list
buttontest . DropDownItems . Clear ( ) ;
2009-04-19 18:07:22 +00:00
// Map loaded?
if ( General . Map ! = null )
{
2015-12-29 11:44:32 +00:00
// Make the new items list
2016-02-21 00:11:09 +00:00
List < ToolStripItem > items = new List < ToolStripItem > ( General . Map . Config . Skills . Count * 2 + General . Map . ConfigSettings . TestEngines . Count + 2 ) ;
2017-02-07 18:02:31 +00:00
// Positive skills are with monsters
foreach ( SkillInfo si in General . Map . Config . Skills )
2009-04-19 18:07:22 +00:00
{
2015-12-29 11:44:32 +00:00
ToolStripMenuItem menuitem = new ToolStripMenuItem ( si . ToString ( ) ) ;
2014-02-21 14:42:12 +00:00
menuitem . Image = Resources . Monster2 ;
menuitem . Click + = TestSkill_Click ;
2015-12-29 11:44:32 +00:00
menuitem . Tag = si . Index ;
menuitem . Checked = ( General . Settings . TestMonsters & & ( General . Map . ConfigSettings . TestSkill = = si . Index ) ) ;
2016-02-21 00:11:09 +00:00
items . Add ( menuitem ) ;
2009-04-19 18:07:22 +00:00
}
// Add seperator
2016-02-21 00:11:09 +00:00
items . Add ( new ToolStripSeparator { Padding = new Padding ( 0 , 3 , 0 , 3 ) } ) ;
2009-04-19 18:07:22 +00:00
2017-02-07 18:02:31 +00:00
// Negative skills are without monsters
foreach ( SkillInfo si in General . Map . Config . Skills )
{
ToolStripMenuItem menuitem = new ToolStripMenuItem ( si . ToString ( ) ) ;
2014-02-21 14:42:12 +00:00
menuitem . Image = Resources . Monster3 ;
menuitem . Click + = TestSkill_Click ;
2015-12-29 11:44:32 +00:00
menuitem . Tag = - si . Index ;
menuitem . Checked = ( ! General . Settings . TestMonsters & & ( General . Map . ConfigSettings . TestSkill = = si . Index ) ) ;
2016-02-21 00:11:09 +00:00
items . Add ( menuitem ) ;
2015-12-29 11:44:32 +00:00
}
//mxd. Add seperator
2016-02-21 00:11:09 +00:00
items . Add ( new ToolStripSeparator { Padding = new Padding ( 0 , 3 , 0 , 3 ) } ) ;
2015-12-29 11:44:32 +00:00
//mxd. Add test engines
for ( int i = 0 ; i < General . Map . ConfigSettings . TestEngines . Count ; i + + )
{
2016-02-21 00:11:09 +00:00
if ( General . Map . ConfigSettings . TestEngines [ i ] . TestProgramName = = EngineInfo . DEFAULT_ENGINE_NAME ) continue ;
2015-12-29 11:44:32 +00:00
ToolStripMenuItem menuitem = new ToolStripMenuItem ( General . Map . ConfigSettings . TestEngines [ i ] . TestProgramName ) ;
menuitem . Image = General . Map . ConfigSettings . TestEngines [ i ] . TestProgramIcon ;
menuitem . Click + = TestEngine_Click ;
menuitem . Tag = i ;
menuitem . Checked = ( i = = General . Map . ConfigSettings . CurrentEngineIndex ) ;
2016-02-21 00:11:09 +00:00
items . Add ( menuitem ) ;
2009-04-19 18:07:22 +00:00
}
// Add to list
2016-02-21 00:11:09 +00:00
buttontest . DropDownItems . AddRange ( items . ToArray ( ) ) ;
2017-02-07 18:02:31 +00:00
}
2009-04-19 18:07:22 +00:00
}
2012-11-02 23:11:38 +00:00
2016-03-04 13:41:55 +00:00
//mxd
internal void DisableDynamicGridResize ( )
{
if ( General . Settings . DynamicGridSize )
{
General . Settings . DynamicGridSize = false ;
itemdynamicgridsize . Checked = false ;
buttontoggledynamicgrid . Checked = false ;
}
}
2013-09-11 09:47:53 +00:00
//mxd
2015-12-29 11:44:32 +00:00
private void TestEngine_Click ( object sender , EventArgs e )
2014-11-10 11:27:37 +00:00
{
2013-09-11 09:47:53 +00:00
General . Map . ConfigSettings . CurrentEngineIndex = ( int ) ( ( ( ToolStripMenuItem ) sender ) . Tag ) ;
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
General . Map . ConfigSettings . Changed = true ;
2015-12-29 11:44:32 +00:00
General . Map . Launcher . TestAtSkill ( General . Map . ConfigSettings . TestSkill ) ;
2013-08-05 13:03:08 +00:00
UpdateSkills ( ) ;
2013-09-11 09:47:53 +00:00
}
2009-04-19 18:07:22 +00:00
// Event handler for testing at a specific skill
private void TestSkill_Click ( object sender , EventArgs e )
{
int skill = ( int ) ( ( sender as ToolStripMenuItem ) . Tag ) ;
General . Settings . TestMonsters = ( skill > 0 ) ;
General . Map . ConfigSettings . TestSkill = Math . Abs ( skill ) ;
General . Map . Launcher . TestAtSkill ( Math . Abs ( skill ) ) ;
UpdateSkills ( ) ;
}
// This loses focus
private void LoseFocus ( object sender , EventArgs e )
{
// Lose focus!
2009-07-21 13:42:36 +00:00
try { display . Focus ( ) ; } catch ( Exception ) { }
2009-04-19 18:07:22 +00:00
this . ActiveControl = null ;
}
2015-07-30 23:48:16 +00:00
//mxd. Things filter selected
private void thingfilters_DropDownItemClicked ( object sender , EventArgs e )
2009-04-19 18:07:22 +00:00
{
// Only possible when a map is open
if ( ( General . Map ! = null ) & & ! updatingfilters )
{
2009-07-05 10:26:57 +00:00
updatingfilters = true ;
2015-07-30 23:48:16 +00:00
ToolStripMenuItem clickeditem = sender as ToolStripMenuItem ;
// Keep already selected items selected
if ( ! clickeditem . Checked )
{
clickeditem . Checked = true ;
updatingfilters = false ;
return ;
}
2009-04-19 18:07:22 +00:00
// Change filter
2015-07-30 23:48:16 +00:00
ThingsFilter f = clickeditem . Tag as ThingsFilter ;
General . Map . ChangeThingFilter ( f ) ;
// Deselect other items...
foreach ( var item in thingfilters . DropDown . Items )
{
if ( item ! = clickeditem ) ( ( ToolStripMenuItem ) item ) . Checked = false ;
}
// Update button text
thingfilters . Text = f . Name ;
2009-07-05 10:26:57 +00:00
updatingfilters = false ;
2009-04-19 18:07:22 +00:00
}
// Lose focus
2015-07-30 23:48:16 +00:00
LoseFocus ( sender , e ) ;
2009-04-19 18:07:22 +00:00
}
2015-07-30 23:48:16 +00:00
//mxd. This updates the things filter on the toolbar
2009-04-19 18:07:22 +00:00
internal void UpdateThingsFilters ( )
{
// Only possible to list filters when a map is open
if ( General . Map ! = null )
{
ThingsFilter oldfilter = null ;
2015-07-30 23:48:16 +00:00
// Anything selected?
foreach ( var item in thingfilters . DropDown . Items )
{
if ( ( ( ToolStripMenuItem ) item ) . Checked )
{
oldfilter = ( ( ToolStripMenuItem ) item ) . Tag as ThingsFilter ;
break ;
}
}
2009-04-19 18:07:22 +00:00
updatingfilters = true ;
// Clear the list
2015-07-30 23:48:16 +00:00
thingfilters . DropDown . Items . Clear ( ) ;
2009-04-19 18:07:22 +00:00
// Add null filter
if ( General . Map . ThingsFilter is NullThingsFilter )
2015-07-30 23:48:16 +00:00
thingfilters . DropDown . Items . Add ( CreateThingsFilterMenuItem ( General . Map . ThingsFilter ) ) ;
2009-04-19 18:07:22 +00:00
else
2015-07-30 23:48:16 +00:00
thingfilters . DropDown . Items . Add ( CreateThingsFilterMenuItem ( new NullThingsFilter ( ) ) ) ;
2009-04-19 18:07:22 +00:00
2015-07-30 23:48:16 +00:00
// Add all filters, select current one
2009-04-19 18:07:22 +00:00
foreach ( ThingsFilter f in General . Map . ConfigSettings . ThingsFilters )
2015-07-30 23:48:16 +00:00
thingfilters . DropDown . Items . Add ( CreateThingsFilterMenuItem ( f ) ) ;
2009-04-19 18:07:22 +00:00
updatingfilters = false ;
// No filter selected?
2015-07-30 23:48:16 +00:00
ToolStripMenuItem selecteditem = null ;
foreach ( var i in thingfilters . DropDown . Items )
{
ToolStripMenuItem item = i as ToolStripMenuItem ;
if ( item . Checked )
{
selecteditem = item ;
break ;
}
}
if ( selecteditem = = null )
2009-04-19 18:07:22 +00:00
{
2015-07-30 23:48:16 +00:00
ToolStripMenuItem first = thingfilters . DropDown . Items [ 0 ] as ToolStripMenuItem ;
first . Checked = true ;
2009-04-19 18:07:22 +00:00
}
// Another filter got selected?
2015-07-30 23:48:16 +00:00
else if ( selecteditem . Tag ! = oldfilter )
2009-04-19 18:07:22 +00:00
{
2015-07-30 23:48:16 +00:00
selecteditem . Checked = true ;
2009-04-19 18:07:22 +00:00
}
2015-07-30 23:48:16 +00:00
// Update button text
if ( selecteditem ! = null )
thingfilters . Text = ( ( ThingsFilter ) selecteditem . Tag ) . Name ;
2009-04-19 18:07:22 +00:00
}
else
{
// Clear the list
2015-07-30 23:48:16 +00:00
thingfilters . DropDown . Items . Clear ( ) ;
thingfilters . Text = "(show all)" ;
2009-04-19 18:07:22 +00:00
}
}
2009-07-05 10:26:57 +00:00
// This selects the things filter based on the filter set on the map manager
internal void ReflectThingsFilter ( )
{
if ( ! updatingfilters )
{
updatingfilters = true ;
// Select current filter
bool selecteditemfound = false ;
2015-07-30 23:48:16 +00:00
foreach ( var i in thingfilters . DropDown . Items )
2009-07-05 10:26:57 +00:00
{
2015-07-30 23:48:16 +00:00
ToolStripMenuItem item = i as ToolStripMenuItem ;
ThingsFilter f = item . Tag as ThingsFilter ;
2009-07-05 10:26:57 +00:00
if ( f = = General . Map . ThingsFilter )
{
2015-07-30 23:48:16 +00:00
item . Checked = true ;
thingfilters . Text = f . Name ;
2009-07-05 10:26:57 +00:00
selecteditemfound = true ;
}
2015-07-30 23:48:16 +00:00
else
{
item . Checked = false ;
}
2009-07-05 10:26:57 +00:00
}
// Not in the list?
if ( ! selecteditemfound )
{
// Select nothing
2015-07-30 23:48:16 +00:00
thingfilters . Text = "(show all)" ; //mxd
2009-07-05 10:26:57 +00:00
}
updatingfilters = false ;
}
}
2015-07-30 23:48:16 +00:00
//mxd
private ToolStripMenuItem CreateThingsFilterMenuItem ( ThingsFilter f )
{
// Make decorated name
string name = f . Name ;
if ( f . Invert ) name = "!" + name ;
switch ( f . DisplayMode )
{
case ThingsFilterDisplayMode . CLASSIC_MODES_ONLY : name + = " [2D]" ; break ;
case ThingsFilterDisplayMode . VISUAL_MODES_ONLY : name + = " [3D]" ; break ;
}
// Create and select the item
ToolStripMenuItem item = new ToolStripMenuItem ( name ) { CheckOnClick = true , Tag = f } ;
item . CheckedChanged + = thingfilters_DropDownItemClicked ;
item . Checked = ( f = = General . Map . ThingsFilter ) ;
// Update icon
if ( ! ( f is NullThingsFilter ) & & ! f . IsValid ( ) )
{
item . Image = Resources . Warning ;
2015-09-25 13:20:53 +00:00
//item.ImageScaling = ToolStripItemImageScaling.None;
2015-07-30 23:48:16 +00:00
}
return item ;
}
//mxd. Linedef color preset (de)selected
private void linedefcolorpresets_ItemClicked ( object sender , EventArgs e )
{
ToolStripMenuItem item = sender as ToolStripMenuItem ;
( ( LinedefColorPreset ) item . Tag ) . Enabled = item . Checked ;
List < string > enablednames = new List < string > ( ) ;
2015-12-28 15:01:53 +00:00
foreach ( LinedefColorPreset p in General . Map . ConfigSettings . LinedefColorPresets )
2015-07-30 23:48:16 +00:00
{
if ( p . Enabled ) enablednames . Add ( p . Name ) ;
}
// Update button text
UpdateColorPresetsButtonText ( linedefcolorpresets , enablednames ) ;
General . Map . Map . UpdateCustomLinedefColors ( ) ;
General . Map . ConfigSettings . Changed = true ;
// Update display
if ( General . Editing . Mode is ClassicMode ) General . Interface . RedrawDisplay ( ) ;
}
//mxd. Handle Shift key...
private void linedefcolorpresets_DropDownItemClicked ( object sender , ToolStripItemClickedEventArgs e )
{
linedefcolorpresets . DropDown . AutoClose = ( ModifierKeys ! = Keys . Shift ) ;
}
//mxd. Handles the mouse leaving linedefcolorpresets.DropDown and clicking on linedefcolorpresets button
private void linedefcolorpresets_MouseLeave ( object sender , EventArgs e )
{
linedefcolorpresets . DropDown . AutoClose = true ;
}
//mxd. This updates linedef color presets selector on the toolbar
internal void UpdateLinedefColorPresets ( )
{
// Refill the list
List < string > enablednames = new List < string > ( ) ;
linedefcolorpresets . DropDown . Items . Clear ( ) ;
if ( General . Map ! = null )
{
foreach ( LinedefColorPreset p in General . Map . ConfigSettings . LinedefColorPresets )
{
// Create menu item
ToolStripMenuItem item = new ToolStripMenuItem ( p . Name )
{
CheckOnClick = true ,
Tag = p ,
2015-09-25 13:20:53 +00:00
//ImageScaling = ToolStripItemImageScaling.None,
2015-07-30 23:48:16 +00:00
Checked = p . Enabled ,
ToolTipText = "Hold Shift to toggle several items at once"
} ;
// Create icon
if ( p . IsValid ( ) )
{
Bitmap icon = new Bitmap ( 16 , 16 ) ;
using ( Graphics g = Graphics . FromImage ( icon ) )
{
g . FillRectangle ( new SolidBrush ( p . Color . ToColor ( ) ) , 2 , 3 , 12 , 10 ) ;
g . DrawRectangle ( Pens . Black , 2 , 3 , 11 , 9 ) ;
}
item . Image = icon ;
}
// Or use the warning icon
else
{
item . Image = Resources . Warning ;
}
item . CheckedChanged + = linedefcolorpresets_ItemClicked ;
linedefcolorpresets . DropDown . Items . Add ( item ) ;
if ( p . Enabled ) enablednames . Add ( p . Name ) ;
}
}
// Update button text
UpdateColorPresetsButtonText ( linedefcolorpresets , enablednames ) ;
}
//mxd
private static void UpdateColorPresetsButtonText ( ToolStripItem button , List < string > names )
{
if ( names . Count = = 0 )
{
button . Text = "No active presets" ;
}
else
{
string text = string . Join ( ", " , names . ToArray ( ) ) ;
if ( TextRenderer . MeasureText ( text , button . Font ) . Width > button . Width )
button . Text = names . Count + ( names . Count . ToString ( CultureInfo . InvariantCulture ) . EndsWith ( "1" ) ? " preset" : " presets" ) + " active" ;
else
button . Text = text ;
}
}
2016-04-04 22:20:49 +00:00
//mxd
public void BeginToolbarUpdate ( )
{
toolbar . SuspendLayout ( ) ;
modestoolbar . SuspendLayout ( ) ;
modecontrolsloolbar . SuspendLayout ( ) ;
}
//mxd
public void EndToolbarUpdate ( )
{
toolbar . ResumeLayout ( true ) ;
modestoolbar . ResumeLayout ( true ) ;
modecontrolsloolbar . ResumeLayout ( true ) ;
}
2009-04-19 18:07:22 +00:00
// This adds a button to the toolbar
2010-08-22 20:56:52 +00:00
public void AddButton ( ToolStripItem button ) { AddButton ( button , ToolbarSection . Custom , General . Plugins . FindPluginByAssembly ( Assembly . GetCallingAssembly ( ) ) ) ; }
public void AddButton ( ToolStripItem button , ToolbarSection section ) { AddButton ( button , section , General . Plugins . FindPluginByAssembly ( Assembly . GetCallingAssembly ( ) ) ) ; }
private void AddButton ( ToolStripItem button , ToolbarSection section , Plugin plugin )
2009-04-19 18:07:22 +00:00
{
// Fix tags to full action names
ToolStripItemCollection items = new ToolStripItemCollection ( toolbar , new ToolStripItem [ 0 ] ) ;
items . Add ( button ) ;
RenameTagsToFullActions ( items , plugin ) ;
2010-08-22 20:56:52 +00:00
// Add to the list so we can update it as needed
PluginToolbarButton buttoninfo = new PluginToolbarButton ( ) ;
buttoninfo . button = button ;
buttoninfo . section = section ;
pluginbuttons . Add ( buttoninfo ) ;
2009-04-19 18:07:22 +00:00
// Bind visible changed event
if ( ! ( button is ToolStripSeparator ) ) button . VisibleChanged + = buttonvisiblechangedhandler ;
2010-08-22 20:56:52 +00:00
// Insert the button in the right section
switch ( section )
{
case ToolbarSection . File : toolbar . Items . Insert ( toolbar . Items . IndexOf ( seperatorfile ) , button ) ; break ;
case ToolbarSection . Script : toolbar . Items . Insert ( toolbar . Items . IndexOf ( seperatorscript ) , button ) ; break ;
case ToolbarSection . UndoRedo : toolbar . Items . Insert ( toolbar . Items . IndexOf ( seperatorundo ) , button ) ; break ;
case ToolbarSection . CopyPaste : toolbar . Items . Insert ( toolbar . Items . IndexOf ( seperatorcopypaste ) , button ) ; break ;
case ToolbarSection . Prefabs : toolbar . Items . Insert ( toolbar . Items . IndexOf ( seperatorprefabs ) , button ) ; break ;
case ToolbarSection . Things : toolbar . Items . Insert ( toolbar . Items . IndexOf ( buttonviewnormal ) , button ) ; break ;
case ToolbarSection . Views : toolbar . Items . Insert ( toolbar . Items . IndexOf ( seperatorviews ) , button ) ; break ;
case ToolbarSection . Geometry : toolbar . Items . Insert ( toolbar . Items . IndexOf ( seperatorgeometry ) , button ) ; break ;
2016-10-03 11:42:12 +00:00
case ToolbarSection . Helpers : toolbar . Items . Insert ( toolbar . Items . IndexOf ( separatorgzmodes ) , button ) ; break ; //mxd
2010-08-22 20:56:52 +00:00
case ToolbarSection . Testing : toolbar . Items . Insert ( toolbar . Items . IndexOf ( seperatortesting ) , button ) ; break ;
2014-02-26 14:11:06 +00:00
case ToolbarSection . Modes : modestoolbar . Items . Add ( button ) ; break ; //mxd
2014-02-27 10:08:31 +00:00
case ToolbarSection . Custom : modecontrolsloolbar . Items . Add ( button ) ; modecontrolsloolbar . Visible = true ; break ; //mxd
2010-08-22 20:56:52 +00:00
}
UpdateToolbar ( ) ;
2009-04-19 18:07:22 +00:00
}
2014-02-26 14:11:06 +00:00
//mxd
2014-12-03 23:15:26 +00:00
public void AddModesButton ( ToolStripItem button , string group )
{
2014-03-04 09:04:43 +00:00
// Set proper styling
button . Padding = new Padding ( 0 , 1 , 0 , 1 ) ;
button . Margin = new Padding ( ) ;
2014-02-26 14:11:06 +00:00
// Fix tags to full action names
ToolStripItemCollection items = new ToolStripItemCollection ( toolbar , new ToolStripItem [ 0 ] ) ;
items . Add ( button ) ;
RenameTagsToFullActions ( items , General . Plugins . FindPluginByAssembly ( Assembly . GetCallingAssembly ( ) ) ) ;
// Add to the list so we can update it as needed
PluginToolbarButton buttoninfo = new PluginToolbarButton ( ) ;
buttoninfo . button = button ;
buttoninfo . section = ToolbarSection . Modes ;
pluginbuttons . Add ( buttoninfo ) ;
button . VisibleChanged + = buttonvisiblechangedhandler ;
//find the separator we need
2014-12-03 23:15:26 +00:00
for ( int i = 0 ; i < modestoolbar . Items . Count ; i + + )
{
if ( modestoolbar . Items [ i ] is ToolStripSeparator & & modestoolbar . Items [ i ] . Text = = group )
{
2014-02-26 14:11:06 +00:00
modestoolbar . Items . Insert ( i + 1 , button ) ;
break ;
}
}
UpdateToolbar ( ) ;
}
2009-04-19 18:07:22 +00:00
// Removes a button
public void RemoveButton ( ToolStripItem button )
{
2010-08-22 20:56:52 +00:00
// Find in the list and remove it
PluginToolbarButton buttoninfo = new PluginToolbarButton ( ) ;
for ( int i = 0 ; i < pluginbuttons . Count ; i + + )
{
if ( pluginbuttons [ i ] . button = = button )
{
buttoninfo = pluginbuttons [ i ] ;
pluginbuttons . RemoveAt ( i ) ;
break ;
}
}
2009-04-19 18:07:22 +00:00
2010-08-22 20:56:52 +00:00
if ( buttoninfo . button ! = null )
{
// Unbind visible changed event
if ( ! ( button is ToolStripSeparator ) ) button . VisibleChanged - = buttonvisiblechangedhandler ;
2014-02-26 14:11:06 +00:00
//mxd. Remove button from toolbars
2015-12-28 15:01:53 +00:00
switch ( buttoninfo . section )
2014-12-03 23:15:26 +00:00
{
2014-02-26 14:11:06 +00:00
case ToolbarSection . Modes :
modestoolbar . Items . Remove ( button ) ;
break ;
case ToolbarSection . Custom :
modecontrolsloolbar . Items . Remove ( button ) ;
2014-02-27 10:08:31 +00:00
modecontrolsloolbar . Visible = ( modecontrolsloolbar . Items . Count > 0 ) ;
2014-02-26 14:11:06 +00:00
break ;
default :
toolbar . Items . Remove ( button ) ;
break ;
}
2010-08-22 20:56:52 +00:00
UpdateSeparators ( ) ;
}
2009-04-19 18:07:22 +00:00
}
// This handle visibility changes in the toolbar buttons
private void ToolbarButtonVisibleChanged ( object sender , EventArgs e )
{
2010-08-22 20:56:52 +00:00
if ( ! preventupdateseperators )
{
// Update the seeprators
UpdateSeparators ( ) ;
}
2009-04-19 18:07:22 +00:00
}
2014-09-17 12:46:47 +00:00
// This hides redundant separators
2009-04-19 18:07:22 +00:00
internal void UpdateSeparators ( )
{
2015-01-25 23:22:42 +00:00
UpdateToolStripSeparators ( toolbar . Items , false ) ;
UpdateToolStripSeparators ( menumode . DropDownItems , true ) ;
2014-02-26 14:11:06 +00:00
//mxd
2015-01-25 23:22:42 +00:00
UpdateToolStripSeparators ( modestoolbar . Items , true ) ;
UpdateToolStripSeparators ( modecontrolsloolbar . Items , true ) ;
2009-04-19 18:07:22 +00:00
}
2015-01-25 23:22:42 +00:00
// This hides redundant separators
private static void UpdateToolStripSeparators ( ToolStripItemCollection items , bool defaultvisible )
2009-04-19 18:07:22 +00:00
{
ToolStripItem pvi = null ;
2015-01-25 23:22:42 +00:00
foreach ( ToolStripItem i in items )
2009-04-19 18:07:22 +00:00
{
2015-01-25 23:22:42 +00:00
bool separatorvisible = false ;
// This is a seperator?
if ( i is ToolStripSeparator )
2009-04-19 18:07:22 +00:00
{
2015-01-25 23:22:42 +00:00
// Make visible when previous item was not a seperator
separatorvisible = ! ( pvi is ToolStripSeparator ) & & ( pvi ! = null ) ;
i . Visible = separatorvisible ;
2009-04-19 18:07:22 +00:00
}
2014-09-17 12:46:47 +00:00
2015-01-25 23:22:42 +00:00
// Keep as previous visible item
if ( i . Visible | | separatorvisible | | ( defaultvisible & & ! ( i is ToolStripSeparator ) ) ) pvi = i ;
2009-04-19 18:07:22 +00:00
}
2015-01-25 23:22:42 +00:00
// Hide last item if it is a seperator
if ( pvi is ToolStripSeparator ) pvi . Visible = false ;
2009-04-19 18:07:22 +00:00
}
// This enables or disables all editing mode items and toolbar buttons
private void UpdateToolbar ( )
{
2010-08-22 20:56:52 +00:00
preventupdateseperators = true ;
2010-08-15 13:45:43 +00:00
// Show/hide items based on preferences
2015-07-14 23:34:31 +00:00
bool maploaded = ( General . Map ! = null ) ; //mxd
2010-08-15 13:45:43 +00:00
buttonnewmap . Visible = General . Settings . ToolbarFile ;
buttonopenmap . Visible = General . Settings . ToolbarFile ;
buttonsavemap . Visible = General . Settings . ToolbarFile ;
2020-06-19 21:30:01 +00:00
buttonscripteditor . Visible = General . Settings . ToolbarScript & & maploaded & & General . Map . Config . HasScriptLumps ( ) ; // Only show script editor if there a script lumps defined
2015-03-05 23:19:10 +00:00
buttonundo . Visible = General . Settings . ToolbarUndo & & maploaded ;
buttonredo . Visible = General . Settings . ToolbarUndo & & maploaded ;
buttoncut . Visible = General . Settings . ToolbarCopy & & maploaded ;
buttoncopy . Visible = General . Settings . ToolbarCopy & & maploaded ;
buttonpaste . Visible = General . Settings . ToolbarCopy & & maploaded ;
buttoninsertprefabfile . Visible = General . Settings . ToolbarPrefabs & & maploaded ;
buttoninsertpreviousprefab . Visible = General . Settings . ToolbarPrefabs & & maploaded ;
buttonthingsfilter . Visible = General . Settings . ToolbarFilter & & maploaded ;
thingfilters . Visible = General . Settings . ToolbarFilter & & maploaded ;
2015-07-30 23:48:16 +00:00
separatorlinecolors . Visible = General . Settings . ToolbarFilter & & maploaded ; //mxd
buttonlinededfcolors . Visible = General . Settings . ToolbarFilter & & maploaded ; //mxd
linedefcolorpresets . Visible = General . Settings . ToolbarFilter & & maploaded ; //mxd
2015-03-05 23:19:10 +00:00
separatorfilters . Visible = General . Settings . ToolbarViewModes & & maploaded ; //mxd
buttonfullbrightness . Visible = General . Settings . ToolbarViewModes & & maploaded ; //mxd
Added, Visual mode, GLDEFS, GLOOME: subtractive glow is now supported.
Changed, Visual mode: changed thing fog calculation logic. Should be closer to GZDoom now.
Fixed, GLDEFS parser: "height" texture parameter was not treated as optional.
Fixed, text lump parsers: in some cases incorrect line number was displayed in error and warning messages.
Fixed, Visual mode: glow effect was not applied to sectors with 3 sidedefs.
Fixed, Visual mode: in some cases glow effect was not updated when replacing textures.
Fixed, general interface: "Full Brightness" button state was not updated during map loading.
Fixed, Drag Linedefs/Vertices/Sectors/Things modes: positions of line length labels were not updated while panning the view.
Cosmetic: added a bunch of new icons.
Cosmetic: changed Visual mode crosshair.
2015-08-27 20:46:49 +00:00
buttonfullbrightness . Checked = Renderer . FullBrightness ; //mxd
2015-08-04 23:28:02 +00:00
buttontogglegrid . Visible = General . Settings . ToolbarViewModes & & maploaded ; //mxd
buttontogglegrid . Checked = General . Settings . RenderGrid ; //mxd
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
buttontogglecomments . Visible = General . Settings . ToolbarViewModes & & maploaded & & General . Map . UDMF ; //mxd
2015-08-23 23:32:12 +00:00
buttontogglecomments . Checked = General . Settings . RenderComments ; //mxd
2016-02-22 15:20:08 +00:00
buttontogglefixedthingsscale . Visible = General . Settings . ToolbarViewModes & & maploaded ; //mxd
buttontogglefixedthingsscale . Checked = General . Settings . FixedThingsScale ; //mxd
2015-03-05 23:19:10 +00:00
separatorfullbrightness . Visible = General . Settings . ToolbarViewModes & & maploaded ; //mxd
buttonviewbrightness . Visible = General . Settings . ToolbarViewModes & & maploaded ;
buttonviewceilings . Visible = General . Settings . ToolbarViewModes & & maploaded ;
buttonviewfloors . Visible = General . Settings . ToolbarViewModes & & maploaded ;
buttonviewnormal . Visible = General . Settings . ToolbarViewModes & & maploaded ;
2016-06-02 09:55:01 +00:00
separatorgeomergemodes . Visible = General . Settings . ToolbarGeometry & & maploaded ; //mxd
buttonmergegeoclassic . Visible = General . Settings . ToolbarGeometry & & maploaded ; //mxd
buttonmergegeo . Visible = General . Settings . ToolbarGeometry & & maploaded ; //mxd
buttonplacegeo . Visible = General . Settings . ToolbarGeometry & & maploaded ; //mxd
2015-03-05 23:19:10 +00:00
buttonsnaptogrid . Visible = General . Settings . ToolbarGeometry & & maploaded ;
2015-08-23 23:32:12 +00:00
buttontoggledynamicgrid . Visible = General . Settings . ToolbarGeometry & & maploaded ; //mxd
buttontoggledynamicgrid . Checked = General . Settings . DynamicGridSize ; //mxd
2015-03-05 23:19:10 +00:00
buttonautomerge . Visible = General . Settings . ToolbarGeometry & & maploaded ;
2016-06-15 22:02:51 +00:00
buttonsplitjoinedsectors . Visible = General . Settings . ToolbarGeometry & & maploaded ; //mxd
buttonsplitjoinedsectors . Checked = General . Settings . SplitJoinedSectors ; //mxd
2015-03-05 23:19:10 +00:00
buttonautoclearsidetextures . Visible = General . Settings . ToolbarGeometry & & maploaded ; //mxd
buttontest . Visible = General . Settings . ToolbarTesting & & maploaded ;
2010-08-15 13:45:43 +00:00
2013-09-11 09:47:53 +00:00
//mxd
2015-03-05 23:19:10 +00:00
modelrendermode . Visible = General . Settings . GZToolbarGZDoom & & maploaded ;
dynamiclightmode . Visible = General . Settings . GZToolbarGZDoom & & maploaded ;
buttontogglefog . Visible = General . Settings . GZToolbarGZDoom & & maploaded ;
2016-01-11 13:00:52 +00:00
buttontogglesky . Visible = General . Settings . GZToolbarGZDoom & & maploaded ;
2015-03-05 23:19:10 +00:00
buttontoggleeventlines . Visible = General . Settings . GZToolbarGZDoom & & maploaded ;
2016-02-17 22:23:18 +00:00
buttontogglevisualvertices . Visible = General . Settings . GZToolbarGZDoom & & maploaded & & General . Map . UDMF ;
2015-03-05 23:19:10 +00:00
separatorgzmodes . Visible = General . Settings . GZToolbarGZDoom & & maploaded ;
2012-04-17 19:13:47 +00:00
2014-02-26 14:11:06 +00:00
//mxd. Show/hide additional panels
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
modestoolbar . Visible = maploaded ;
panelinfo . Visible = maploaded ;
modecontrolsloolbar . Visible = ( maploaded & & modecontrolsloolbar . Items . Count > 0 ) ;
2014-10-20 12:16:51 +00:00
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
//mxd. modestoolbar index in Controls gets messed up when it's invisible. This fixes it.
//TODO: find out why this happens in the first place
2014-10-20 12:16:51 +00:00
if ( modestoolbar . Visible )
{
2014-02-26 14:11:06 +00:00
int toolbarpos = this . Controls . IndexOf ( toolbar ) ;
2014-10-20 12:16:51 +00:00
if ( this . Controls . IndexOf ( modestoolbar ) > toolbarpos )
{
2014-02-26 14:11:06 +00:00
this . Controls . SetChildIndex ( modestoolbar , toolbarpos ) ;
}
}
2010-08-22 20:56:52 +00:00
// Update plugin buttons
foreach ( PluginToolbarButton p in pluginbuttons )
{
switch ( p . section )
{
case ToolbarSection . File : p . button . Visible = General . Settings . ToolbarFile ; break ;
case ToolbarSection . Script : p . button . Visible = General . Settings . ToolbarScript ; break ;
case ToolbarSection . UndoRedo : p . button . Visible = General . Settings . ToolbarUndo ; break ;
case ToolbarSection . CopyPaste : p . button . Visible = General . Settings . ToolbarCopy ; break ;
case ToolbarSection . Prefabs : p . button . Visible = General . Settings . ToolbarPrefabs ; break ;
case ToolbarSection . Things : p . button . Visible = General . Settings . ToolbarFilter ; break ;
case ToolbarSection . Views : p . button . Visible = General . Settings . ToolbarViewModes ; break ;
case ToolbarSection . Geometry : p . button . Visible = General . Settings . ToolbarGeometry ; break ;
case ToolbarSection . Testing : p . button . Visible = General . Settings . ToolbarTesting ; break ;
}
}
preventupdateseperators = false ;
2010-08-15 13:45:43 +00:00
UpdateSeparators ( ) ;
2009-04-19 18:07:22 +00:00
}
// This checks one of the edit mode items (and unchecks all others)
internal void CheckEditModeButton ( string modeclassname )
{
2019-01-14 18:07:08 +00:00
// Go for all items
//foreach(ToolStripItem item in editmodeitems)
int itemCount = editmodeitems . Count ;
for ( int i = 0 ; i < itemCount ; i + + )
2009-04-19 18:07:22 +00:00
{
2019-01-14 18:07:08 +00:00
ToolStripItem item = editmodeitems [ i ] ;
2009-04-19 18:07:22 +00:00
// Check what type it is
2017-02-08 12:18:01 +00:00
if ( item is ToolStripMenuItem )
2009-04-19 18:07:22 +00:00
{
// Check if mode type matches with given name
2017-02-08 12:18:01 +00:00
( item as ToolStripMenuItem ) . Checked = ( ( item . Tag as EditModeInfo ) . Type . Name = = modeclassname ) ;
2009-04-19 18:07:22 +00:00
}
2017-02-08 12:18:01 +00:00
else if ( item is ToolStripButton )
2009-04-19 18:07:22 +00:00
{
// Check if mode type matches with given name
2017-02-08 12:18:01 +00:00
( item as ToolStripButton ) . Checked = ( ( item . Tag as EditModeInfo ) . Type . Name = = modeclassname ) ;
2009-04-19 18:07:22 +00:00
}
}
}
// This removes the config-specific editing mode buttons
internal void RemoveEditModeButtons ( )
{
2019-01-14 18:07:08 +00:00
// Go for all items
//foreach(ToolStripItem item in editmodeitems)
int itemCount = editmodeitems . Count ;
for ( int i = 0 ; i < itemCount ; i + + )
{
ToolStripItem item = editmodeitems [ i ] ;
// Remove it and restart
menumode . DropDownItems . Remove ( item ) ;
2017-02-08 12:18:01 +00:00
item . Dispose ( ) ;
2009-04-19 18:07:22 +00:00
}
// Done
2014-03-04 09:04:43 +00:00
modestoolbar . Items . Clear ( ) ; //mxd
2009-04-19 18:07:22 +00:00
editmodeitems . Clear ( ) ;
UpdateSeparators ( ) ;
}
// This adds an editing mode seperator on the toolbar and menu
2014-02-26 14:11:06 +00:00
internal void AddEditModeSeperator ( string group )
2009-04-19 18:07:22 +00:00
{
// Create a button
2014-02-26 14:11:06 +00:00
ToolStripSeparator item = new ToolStripSeparator ( ) ;
item . Text = group ; //mxd
2014-03-04 09:04:43 +00:00
item . Margin = new Padding ( 0 , 3 , 0 , 3 ) ; //mxd
2014-02-26 14:11:06 +00:00
modestoolbar . Items . Add ( item ) ; //mxd
2009-04-19 18:07:22 +00:00
editmodeitems . Add ( item ) ;
// Create menu item
2014-02-26 14:11:06 +00:00
int index = menumode . DropDownItems . Count ;
2009-04-19 18:07:22 +00:00
item = new ToolStripSeparator ( ) ;
2014-02-26 14:11:06 +00:00
item . Text = group ; //mxd
2009-04-19 18:07:22 +00:00
item . Margin = new Padding ( 0 , 3 , 0 , 3 ) ;
menumode . DropDownItems . Insert ( index , item ) ;
editmodeitems . Add ( item ) ;
UpdateSeparators ( ) ;
}
// This adds an editing mode button to the toolbar and edit menu
internal void AddEditModeButton ( EditModeInfo modeinfo )
{
string controlname = modeinfo . ButtonDesc . Replace ( "&" , "&&" ) ;
// Create a button
2014-02-26 14:11:06 +00:00
ToolStripItem item = new ToolStripButton ( modeinfo . ButtonDesc , modeinfo . ButtonImage , EditModeButtonHandler ) ;
2009-04-19 18:07:22 +00:00
item . DisplayStyle = ToolStripItemDisplayStyle . Image ;
2014-03-04 09:04:43 +00:00
item . Padding = new Padding ( 0 , 2 , 0 , 2 ) ;
item . Margin = new Padding ( ) ;
2009-04-19 18:07:22 +00:00
item . Tag = modeinfo ;
2014-02-26 14:11:06 +00:00
modestoolbar . Items . Add ( item ) ; //mxd
2009-04-19 18:07:22 +00:00
editmodeitems . Add ( item ) ;
// Create menu item
2014-02-26 14:11:06 +00:00
int index = menumode . DropDownItems . Count ;
2014-02-21 14:42:12 +00:00
item = new ToolStripMenuItem ( controlname , modeinfo . ButtonImage , EditModeButtonHandler ) ;
2009-04-19 18:07:22 +00:00
item . Tag = modeinfo ;
menumode . DropDownItems . Insert ( index , item ) ;
editmodeitems . Add ( item ) ;
item . Visible = true ;
ApplyShortcutKeys ( menumode . DropDownItems ) ;
UpdateSeparators ( ) ;
}
// This handles edit mode button clicks
private void EditModeButtonHandler ( object sender , EventArgs e )
{
this . Update ( ) ;
2014-02-26 14:11:06 +00:00
EditModeInfo modeinfo = ( EditModeInfo ) ( ( sender as ToolStripItem ) . Tag ) ;
2009-04-19 18:07:22 +00:00
General . Actions . InvokeAction ( modeinfo . SwitchAction . GetFullActionName ( modeinfo . Plugin . Assembly ) ) ;
this . Update ( ) ;
}
2013-09-11 09:47:53 +00:00
//mxd
2014-10-20 12:16:51 +00:00
public void UpdateGZDoomPanel ( )
{
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
if ( General . Map ! = null & & General . Settings . GZToolbarGZDoom )
2014-10-20 12:16:51 +00:00
{
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
foreach ( ToolStripMenuItem item in modelrendermode . DropDownItems )
{
item . Checked = ( ( ModelRenderMode ) item . Tag = = General . Settings . GZDrawModelsMode ) ;
if ( item . Checked ) modelrendermode . Image = item . Image ;
}
2012-05-11 12:28:20 +00:00
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
foreach ( ToolStripMenuItem item in dynamiclightmode . DropDownItems )
2014-10-20 12:16:51 +00:00
{
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
item . Checked = ( ( LightRenderMode ) item . Tag = = General . Settings . GZDrawLightsMode ) ;
if ( item . Checked ) dynamiclightmode . Image = item . Image ;
2013-09-11 09:47:53 +00:00
}
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
buttontogglefog . Checked = General . Settings . GZDrawFog ;
2016-01-11 13:00:52 +00:00
buttontogglesky . Checked = General . Settings . GZDrawSky ;
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
buttontoggleeventlines . Checked = General . Settings . GZShowEventLines ;
buttontogglevisualvertices . Visible = General . Map . UDMF ;
buttontogglevisualvertices . Checked = General . Settings . GZShowVisualVertices ;
2014-10-20 12:16:51 +00:00
}
2013-09-11 09:47:53 +00:00
}
2012-04-17 19:13:47 +00:00
2009-04-19 18:07:22 +00:00
#endregion
2013-09-13 14:54:43 +00:00
#region = = = = = = = = = = = = = = = = = = Toolbar context menu ( mxd )
2013-04-01 11:06:01 +00:00
2015-03-05 23:19:10 +00:00
private void toolbarContextMenu_Opening ( object sender , CancelEventArgs e )
2014-12-03 23:15:26 +00:00
{
2015-03-05 23:19:10 +00:00
if ( General . Map = = null )
{
e . Cancel = true ;
return ;
}
2013-04-01 11:06:01 +00:00
toggleFile . Image = General . Settings . ToolbarFile ? Resources . Check : null ;
toggleScript . Image = General . Settings . ToolbarScript ? Resources . Check : null ;
toggleUndo . Image = General . Settings . ToolbarUndo ? Resources . Check : null ;
toggleCopy . Image = General . Settings . ToolbarCopy ? Resources . Check : null ;
togglePrefabs . Image = General . Settings . ToolbarPrefabs ? Resources . Check : null ;
toggleFilter . Image = General . Settings . ToolbarFilter ? Resources . Check : null ;
toggleViewModes . Image = General . Settings . ToolbarViewModes ? Resources . Check : null ;
toggleGeometry . Image = General . Settings . ToolbarGeometry ? Resources . Check : null ;
toggleTesting . Image = General . Settings . ToolbarTesting ? Resources . Check : null ;
toggleRendering . Image = General . Settings . GZToolbarGZDoom ? Resources . Check : null ;
}
2014-12-03 23:15:26 +00:00
private void toolbarContextMenu_Closing ( object sender , ToolStripDropDownClosingEventArgs e )
{
2015-03-23 14:19:23 +00:00
e . Cancel = ( e . CloseReason = = ToolStripDropDownCloseReason . ItemClicked & & toolbarContextMenuShiftPressed ) ;
2013-04-01 11:06:01 +00:00
}
2014-12-03 23:15:26 +00:00
private void toolbarContextMenu_KeyDown ( object sender , KeyEventArgs e )
{
2014-03-04 09:04:43 +00:00
toolbarContextMenuShiftPressed = ( e . KeyCode = = Keys . ShiftKey ) ;
2013-04-01 11:06:01 +00:00
}
2014-12-03 23:15:26 +00:00
private void toolbarContextMenu_KeyUp ( object sender , KeyEventArgs e )
{
2014-03-04 09:04:43 +00:00
toolbarContextMenuShiftPressed = ( e . KeyCode ! = Keys . ShiftKey ) ;
2013-04-01 11:06:01 +00:00
}
2014-12-03 23:15:26 +00:00
private void toggleFile_Click ( object sender , EventArgs e )
{
2013-04-01 11:06:01 +00:00
General . Settings . ToolbarFile = ! General . Settings . ToolbarFile ;
UpdateToolbar ( ) ;
if ( toolbarContextMenuShiftPressed )
toggleFile . Image = General . Settings . ToolbarFile ? Resources . Check : null ;
}
2014-12-03 23:15:26 +00:00
private void toggleScript_Click ( object sender , EventArgs e )
{
2013-04-01 11:06:01 +00:00
General . Settings . ToolbarScript = ! General . Settings . ToolbarScript ;
UpdateToolbar ( ) ;
if ( toolbarContextMenuShiftPressed )
toggleScript . Image = General . Settings . ToolbarScript ? Resources . Check : null ;
}
2014-12-03 23:15:26 +00:00
private void toggleUndo_Click ( object sender , EventArgs e )
{
2013-04-01 11:06:01 +00:00
General . Settings . ToolbarUndo = ! General . Settings . ToolbarUndo ;
UpdateToolbar ( ) ;
if ( toolbarContextMenuShiftPressed )
toggleUndo . Image = General . Settings . ToolbarUndo ? Resources . Check : null ;
}
2014-12-03 23:15:26 +00:00
private void toggleCopy_Click ( object sender , EventArgs e )
{
2013-04-01 11:06:01 +00:00
General . Settings . ToolbarCopy = ! General . Settings . ToolbarCopy ;
UpdateToolbar ( ) ;
if ( toolbarContextMenuShiftPressed )
toggleCopy . Image = General . Settings . ToolbarCopy ? Resources . Check : null ;
}
2014-12-03 23:15:26 +00:00
private void togglePrefabs_Click ( object sender , EventArgs e )
{
2013-04-01 11:06:01 +00:00
General . Settings . ToolbarPrefabs = ! General . Settings . ToolbarPrefabs ;
UpdateToolbar ( ) ;
if ( toolbarContextMenuShiftPressed )
togglePrefabs . Image = General . Settings . ToolbarPrefabs ? Resources . Check : null ;
}
2014-12-03 23:15:26 +00:00
private void toggleFilter_Click ( object sender , EventArgs e )
{
2013-04-01 11:06:01 +00:00
General . Settings . ToolbarFilter = ! General . Settings . ToolbarFilter ;
UpdateToolbar ( ) ;
if ( toolbarContextMenuShiftPressed )
toggleFilter . Image = General . Settings . ToolbarFilter ? Resources . Check : null ;
}
2014-12-03 23:15:26 +00:00
private void toggleViewModes_Click ( object sender , EventArgs e )
{
2013-04-01 11:06:01 +00:00
General . Settings . ToolbarViewModes = ! General . Settings . ToolbarViewModes ;
UpdateToolbar ( ) ;
if ( toolbarContextMenuShiftPressed )
toggleViewModes . Image = General . Settings . ToolbarViewModes ? Resources . Check : null ;
}
2014-12-03 23:15:26 +00:00
private void toggleGeometry_Click ( object sender , EventArgs e )
{
2013-04-01 11:06:01 +00:00
General . Settings . ToolbarGeometry = ! General . Settings . ToolbarGeometry ;
UpdateToolbar ( ) ;
if ( toolbarContextMenuShiftPressed )
toggleGeometry . Image = General . Settings . ToolbarGeometry ? Resources . Check : null ;
}
2014-12-03 23:15:26 +00:00
private void toggleTesting_Click ( object sender , EventArgs e )
{
2013-04-01 11:06:01 +00:00
General . Settings . ToolbarTesting = ! General . Settings . ToolbarTesting ;
UpdateToolbar ( ) ;
if ( toolbarContextMenuShiftPressed )
toggleTesting . Image = General . Settings . ToolbarTesting ? Resources . Check : null ;
}
2014-12-03 23:15:26 +00:00
private void toggleRendering_Click ( object sender , EventArgs e )
{
2013-04-01 11:06:01 +00:00
General . Settings . GZToolbarGZDoom = ! General . Settings . GZToolbarGZDoom ;
UpdateToolbar ( ) ;
if ( toolbarContextMenuShiftPressed )
toggleRendering . Image = General . Settings . GZToolbarGZDoom ? Resources . Check : null ;
}
#endregion
2009-04-19 18:07:22 +00:00
#region = = = = = = = = = = = = = = = = = = Menus
// This adds a menu to the menus bar
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
public void AddMenu ( ToolStripItem menu ) { AddMenu ( menu , MenuSection . Top , General . Plugins . FindPluginByAssembly ( Assembly . GetCallingAssembly ( ) ) ) ; }
public void AddMenu ( ToolStripItem menu , MenuSection section ) { AddMenu ( menu , section , General . Plugins . FindPluginByAssembly ( Assembly . GetCallingAssembly ( ) ) ) ; }
private void AddMenu ( ToolStripItem menu , MenuSection section , Plugin plugin )
2009-04-19 18:07:22 +00:00
{
// Fix tags to full action names
2010-08-23 09:58:30 +00:00
ToolStripItemCollection items = new ToolStripItemCollection ( this . menumain , new ToolStripItem [ 0 ] ) ;
items . Add ( menu ) ;
RenameTagsToFullActions ( items , plugin ) ;
// Insert the menu in the right location
switch ( section )
{
case MenuSection . FileNewOpenClose : menufile . DropDownItems . Insert ( menufile . DropDownItems . IndexOf ( seperatorfileopen ) , menu ) ; break ;
case MenuSection . FileSave : menufile . DropDownItems . Insert ( menufile . DropDownItems . IndexOf ( seperatorfilesave ) , menu ) ; break ;
2014-03-19 13:03:47 +00:00
case MenuSection . FileImport : itemimport . DropDownItems . Add ( menu ) ; break ; //mxd
case MenuSection . FileExport : itemexport . DropDownItems . Add ( menu ) ; break ; //mxd
2010-08-23 09:58:30 +00:00
case MenuSection . FileRecent : menufile . DropDownItems . Insert ( menufile . DropDownItems . IndexOf ( seperatorfilerecent ) , menu ) ; break ;
case MenuSection . FileExit : menufile . DropDownItems . Insert ( menufile . DropDownItems . IndexOf ( itemexit ) , menu ) ; break ;
case MenuSection . EditUndoRedo : menuedit . DropDownItems . Insert ( menuedit . DropDownItems . IndexOf ( seperatoreditundo ) , menu ) ; break ;
case MenuSection . EditCopyPaste : menuedit . DropDownItems . Insert ( menuedit . DropDownItems . IndexOf ( seperatoreditcopypaste ) , menu ) ; break ;
case MenuSection . EditGeometry : menuedit . DropDownItems . Insert ( menuedit . DropDownItems . IndexOf ( seperatoreditgeometry ) , menu ) ; break ;
case MenuSection . EditGrid : menuedit . DropDownItems . Insert ( menuedit . DropDownItems . IndexOf ( seperatoreditgrid ) , menu ) ; break ;
case MenuSection . EditMapOptions : menuedit . DropDownItems . Add ( menu ) ; break ;
2016-10-03 11:42:12 +00:00
case MenuSection . ViewHelpers : menuview . DropDownItems . Insert ( menuview . DropDownItems . IndexOf ( separatorhelpers ) , menu ) ; break ; //mxd
case MenuSection . ViewRendering : menuview . DropDownItems . Insert ( menuview . DropDownItems . IndexOf ( separatorrendering ) , menu ) ; break ; //mxd
2010-08-23 09:58:30 +00:00
case MenuSection . ViewThings : menuview . DropDownItems . Insert ( menuview . DropDownItems . IndexOf ( seperatorviewthings ) , menu ) ; break ;
case MenuSection . ViewViews : menuview . DropDownItems . Insert ( menuview . DropDownItems . IndexOf ( seperatorviewviews ) , menu ) ; break ;
case MenuSection . ViewZoom : menuview . DropDownItems . Insert ( menuview . DropDownItems . IndexOf ( seperatorviewzoom ) , menu ) ; break ;
case MenuSection . ViewScriptEdit : menuview . DropDownItems . Add ( menu ) ; break ;
case MenuSection . PrefabsInsert : menuprefabs . DropDownItems . Insert ( menuprefabs . DropDownItems . IndexOf ( seperatorprefabsinsert ) , menu ) ; break ;
case MenuSection . PrefabsCreate : menuprefabs . DropDownItems . Add ( menu ) ; break ;
case MenuSection . ToolsResources : menutools . DropDownItems . Insert ( menutools . DropDownItems . IndexOf ( seperatortoolsresources ) , menu ) ; break ;
case MenuSection . ToolsConfiguration : menutools . DropDownItems . Insert ( menutools . DropDownItems . IndexOf ( seperatortoolsconfig ) , menu ) ; break ;
case MenuSection . ToolsTesting : menutools . DropDownItems . Add ( menu ) ; break ;
case MenuSection . HelpManual : menuhelp . DropDownItems . Insert ( menuhelp . DropDownItems . IndexOf ( seperatorhelpmanual ) , menu ) ; break ;
case MenuSection . HelpAbout : menuhelp . DropDownItems . Add ( menu ) ; break ;
case MenuSection . Top : menumain . Items . Insert ( menumain . Items . IndexOf ( menutools ) , menu ) ; break ;
}
2009-04-19 18:07:22 +00:00
2010-08-23 09:58:30 +00:00
ApplyShortcutKeys ( items ) ;
2009-04-19 18:07:22 +00:00
}
2014-02-26 14:11:06 +00:00
//mxd
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
public void AddModesMenu ( ToolStripItem menu , string group )
2014-12-03 23:15:26 +00:00
{
2014-02-26 14:11:06 +00:00
// Fix tags to full action names
ToolStripItemCollection items = new ToolStripItemCollection ( this . menumain , new ToolStripItem [ 0 ] ) ;
items . Add ( menu ) ;
RenameTagsToFullActions ( items , General . Plugins . FindPluginByAssembly ( Assembly . GetCallingAssembly ( ) ) ) ;
//find the separator we need
2014-12-03 23:15:26 +00:00
for ( int i = 0 ; i < menumode . DropDownItems . Count ; i + + )
{
if ( menumode . DropDownItems [ i ] is ToolStripSeparator & & menumode . DropDownItems [ i ] . Text = = group )
{
2014-02-26 14:11:06 +00:00
menumode . DropDownItems . Insert ( i + 1 , menu ) ;
break ;
}
}
ApplyShortcutKeys ( items ) ;
}
2009-04-19 18:07:22 +00:00
// Removes a menu
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
public void RemoveMenu ( ToolStripItem menu )
2009-04-19 18:07:22 +00:00
{
2010-08-23 09:58:30 +00:00
// We actually have no idea in which menu this item is,
// so try removing from all menus and the top strip
menufile . DropDownItems . Remove ( menu ) ;
menuedit . DropDownItems . Remove ( menu ) ;
2014-02-26 14:11:06 +00:00
menumode . DropDownItems . Remove ( menu ) ; //mxd
2010-08-23 09:58:30 +00:00
menuview . DropDownItems . Remove ( menu ) ;
menuprefabs . DropDownItems . Remove ( menu ) ;
menutools . DropDownItems . Remove ( menu ) ;
menuhelp . DropDownItems . Remove ( menu ) ;
2009-04-19 18:07:22 +00:00
menumain . Items . Remove ( menu ) ;
}
2010-08-23 09:58:30 +00:00
2009-04-19 18:07:22 +00:00
// Public method to apply shortcut keys
internal void ApplyShortcutKeys ( )
{
// Apply shortcut keys to menus
ApplyShortcutKeys ( menumain . Items ) ;
}
// This sets the shortcut keys on menu items
2014-05-20 09:09:28 +00:00
private static void ApplyShortcutKeys ( ToolStripItemCollection items )
2009-04-19 18:07:22 +00:00
{
// Go for all controls to find menu items
foreach ( ToolStripItem item in items )
{
// This is a menu item?
if ( item is ToolStripMenuItem )
{
// Get the item in proper type
ToolStripMenuItem menuitem = ( item as ToolStripMenuItem ) ;
// Tag set for this item?
if ( menuitem . Tag is string )
{
// Action with this name available?
string actionname = menuitem . Tag . ToString ( ) ;
if ( General . Actions . Exists ( actionname ) )
{
// Put the action shortcut key on the menu item
menuitem . ShortcutKeyDisplayString = Actions . Action . GetShortcutKeyDesc ( General . Actions [ actionname ] . ShortcutKey ) ;
}
}
// Edit mode info set for this item?
else if ( menuitem . Tag is EditModeInfo )
{
// Action with this name available?
2016-03-18 12:52:12 +00:00
EditModeInfo modeinfo = ( EditModeInfo ) menuitem . Tag ;
2009-04-19 18:07:22 +00:00
string actionname = modeinfo . SwitchAction . GetFullActionName ( modeinfo . Plugin . Assembly ) ;
if ( General . Actions . Exists ( actionname ) )
{
// Put the action shortcut key on the menu item
menuitem . ShortcutKeyDisplayString = Actions . Action . GetShortcutKeyDesc ( General . Actions [ actionname ] . ShortcutKey ) ;
}
}
// Recursively apply shortcut keys to child menu items as well
ApplyShortcutKeys ( menuitem . DropDownItems ) ;
}
}
}
// This fixes short action names to fully qualified
// action names on menu item tags
2014-05-20 09:09:28 +00:00
private static void RenameTagsToFullActions ( ToolStripItemCollection items , Plugin plugin )
2009-04-19 18:07:22 +00:00
{
// Go for all controls to find menu items
foreach ( ToolStripItem item in items )
{
// Tag set for this item?
2014-05-20 09:09:28 +00:00
if ( item . Tag is string )
2009-04-19 18:07:22 +00:00
{
2016-03-18 12:52:12 +00:00
// Check if the tag does not already begin with the assembly name
if ( ! ( ( string ) item . Tag ) . StartsWith ( plugin . Name + "_" , StringComparison . OrdinalIgnoreCase ) )
2009-04-19 18:07:22 +00:00
{
// Change the tag to a fully qualified action name
2016-03-18 12:52:12 +00:00
item . Tag = plugin . Name . ToLowerInvariant ( ) + "_" + ( string ) item . Tag ;
2009-04-19 18:07:22 +00:00
}
}
// This is a menu item?
if ( item is ToolStripMenuItem )
{
// Get the item in proper type
ToolStripMenuItem menuitem = ( item as ToolStripMenuItem ) ;
// Recursively perform operation on child menu items
RenameTagsToFullActions ( menuitem . DropDownItems , plugin ) ;
}
}
}
#endregion
#region = = = = = = = = = = = = = = = = = = File Menu
// This sets up the file menu
private void UpdateFileMenu ( )
{
2015-10-23 12:29:35 +00:00
//mxd. Show/hide items
bool show = ( General . Map ! = null ) ; //mxd
itemclosemap . Visible = show ;
itemsavemap . Visible = show ;
itemsavemapas . Visible = show ;
itemsavemapinto . Visible = show ;
itemopenmapincurwad . Visible = show ; //mxd
itemimport . Visible = show ; //mxd
itemexport . Visible = show ; //mxd
seperatorfileopen . Visible = show ; //mxd
seperatorfilesave . Visible = show ; //mxd
2009-04-19 18:07:22 +00:00
// Toolbar icons
2015-10-23 12:29:35 +00:00
buttonsavemap . Enabled = show ;
2009-04-19 18:07:22 +00:00
}
// This sets the recent files from configuration
private void CreateRecentFiles ( )
{
bool anyitems = false ;
2015-12-28 15:01:53 +00:00
2009-04-19 18:07:22 +00:00
// Where to insert
2013-09-16 13:41:00 +00:00
int insertindex = menufile . DropDownItems . IndexOf ( itemnorecent ) ;
2009-04-19 18:07:22 +00:00
// Create all items
2013-09-16 13:41:00 +00:00
recentitems = new ToolStripMenuItem [ General . Settings . MaxRecentFiles ] ;
for ( int i = 0 ; i < General . Settings . MaxRecentFiles ; i + + )
2009-04-19 18:07:22 +00:00
{
// Create item
recentitems [ i ] = new ToolStripMenuItem ( "" ) ;
recentitems [ i ] . Tag = "" ;
2014-02-21 14:42:12 +00:00
recentitems [ i ] . Click + = recentitem_Click ;
2009-04-19 18:07:22 +00:00
menufile . DropDownItems . Insert ( insertindex + i , recentitems [ i ] ) ;
// Get configuration setting
2015-12-28 15:01:53 +00:00
string filename = General . Settings . ReadSetting ( "recentfiles.file" + i , "" ) ;
2016-02-01 22:04:00 +00:00
if ( ! string . IsNullOrEmpty ( filename ) & & File . Exists ( filename ) )
2009-04-19 18:07:22 +00:00
{
// Set up item
2010-08-12 21:00:54 +00:00
int number = i + 1 ;
2014-02-21 14:42:12 +00:00
recentitems [ i ] . Text = "&" + number + " " + GetDisplayFilename ( filename ) ;
2009-04-19 18:07:22 +00:00
recentitems [ i ] . Tag = filename ;
recentitems [ i ] . Visible = true ;
anyitems = true ;
}
else
{
// Hide item
recentitems [ i ] . Visible = false ;
}
}
// Hide the no recent item when there are items
itemnorecent . Visible = ! anyitems ;
}
// This saves the recent files list
private void SaveRecentFiles ( )
{
// Go for all items
2013-09-16 13:41:00 +00:00
for ( int i = 0 ; i < recentitems . Length ; i + + )
2009-04-19 18:07:22 +00:00
{
// Recent file set?
2016-02-01 22:04:00 +00:00
if ( ! string . IsNullOrEmpty ( recentitems [ i ] . Text ) )
2009-04-19 18:07:22 +00:00
{
// Save to configuration
General . Settings . WriteSetting ( "recentfiles.file" + i , recentitems [ i ] . Tag . ToString ( ) ) ;
}
}
2021-04-02 10:13:22 +00:00
// Save program configuration
General . SaveSettings ( ) ;
2009-04-19 18:07:22 +00:00
}
// This adds a recent file to the list
internal void AddRecentFile ( string filename )
{
2013-09-16 13:41:00 +00:00
//mxd. Recreate recent files list
2016-03-16 23:26:53 +00:00
if ( recentitems . Length ! = General . Settings . MaxRecentFiles )
2014-12-03 23:15:26 +00:00
{
2016-03-16 23:26:53 +00:00
UpdateRecentItems ( ) ;
2013-09-16 13:41:00 +00:00
}
int movedownto = General . Settings . MaxRecentFiles - 1 ;
2009-04-19 18:07:22 +00:00
// Check if this file is already in the list
2013-09-16 13:41:00 +00:00
for ( int i = 0 ; i < General . Settings . MaxRecentFiles ; i + + )
2009-04-19 18:07:22 +00:00
{
// File same as this item?
if ( string . Compare ( filename , recentitems [ i ] . Tag . ToString ( ) , true ) = = 0 )
{
// Move down to here so that this item will disappear
movedownto = i ;
break ;
}
}
// Go for all items, except the last one, backwards
for ( int i = movedownto - 1 ; i > = 0 ; i - - )
{
// Move recent file down the list
2010-08-12 21:00:54 +00:00
int number = i + 2 ;
2014-02-21 14:42:12 +00:00
recentitems [ i + 1 ] . Text = "&" + number + " " + GetDisplayFilename ( recentitems [ i ] . Tag . ToString ( ) ) ;
2009-04-19 18:07:22 +00:00
recentitems [ i + 1 ] . Tag = recentitems [ i ] . Tag . ToString ( ) ;
2016-02-01 22:04:00 +00:00
recentitems [ i + 1 ] . Visible = ! string . IsNullOrEmpty ( recentitems [ i ] . Tag . ToString ( ) ) ;
2009-04-19 18:07:22 +00:00
}
// Add new file at the top
2010-08-15 14:30:51 +00:00
recentitems [ 0 ] . Text = "&1 " + GetDisplayFilename ( filename ) ;
2009-04-19 18:07:22 +00:00
recentitems [ 0 ] . Tag = filename ;
recentitems [ 0 ] . Visible = true ;
// Hide the no recent item
itemnorecent . Visible = false ;
2021-04-02 10:13:22 +00:00
SaveRecentFiles ( ) ;
2009-04-19 18:07:22 +00:00
}
2016-03-16 23:26:53 +00:00
//mxd
private void UpdateRecentItems ( )
{
foreach ( ToolStripMenuItem item in recentitems )
menufile . DropDownItems . Remove ( item ) ;
2021-04-02 10:13:22 +00:00
//SaveRecentFiles();
2016-03-16 23:26:53 +00:00
CreateRecentFiles ( ) ;
}
2009-04-19 18:07:22 +00:00
// This returns the trimmed file/path string
private string GetDisplayFilename ( string filename )
{
// String doesnt fit?
2016-04-06 11:44:38 +00:00
if ( MeasureString ( filename , this . Font ) . Width > MAX_RECENT_FILES_PIXELS )
2009-04-19 18:07:22 +00:00
{
// Start chopping off characters
for ( int i = filename . Length - 6 ; i > = 0 ; i - - )
{
// Does it fit now?
2015-12-28 15:01:53 +00:00
string newname = filename . Substring ( 0 , 3 ) + "..." + filename . Substring ( filename . Length - i , i ) ;
2016-04-06 11:44:38 +00:00
if ( MeasureString ( newname , this . Font ) . Width < = MAX_RECENT_FILES_PIXELS ) return newname ;
2009-04-19 18:07:22 +00:00
}
// Cant find anything that fits (most unlikely!)
return "wtf?!" ;
}
else
{
// The whole string fits
return filename ;
}
}
// Exit clicked
private void itemexit_Click ( object sender , EventArgs e ) { this . Close ( ) ; }
// Recent item clicked
private void recentitem_Click ( object sender , EventArgs e )
{
// Get the item that was clicked
ToolStripItem item = ( sender as ToolStripItem ) ;
// Open this file
2011-07-26 20:06:38 +00:00
General . OpenMapFile ( item . Tag . ToString ( ) , null ) ;
2009-04-19 18:07:22 +00:00
}
2016-03-16 23:26:53 +00:00
//mxd
private void menufile_DropDownOpening ( object sender , EventArgs e )
{
UpdateRecentItems ( ) ;
}
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Edit Menu
// This sets up the edit menu
private void UpdateEditMenu ( )
{
// No edit menu when no map open
2015-03-05 23:19:10 +00:00
menuedit . Visible = ( General . Map ! = null ) ;
2009-04-19 18:07:22 +00:00
// Enable/disable items
itemundo . Enabled = ( General . Map ! = null ) & & ( General . Map . UndoRedo . NextUndo ! = null ) ;
itemredo . Enabled = ( General . Map ! = null ) & & ( General . Map . UndoRedo . NextRedo ! = null ) ;
itemcut . Enabled = ( General . Map ! = null ) & & ( General . Editing . Mode ! = null ) & & General . Editing . Mode . Attributes . AllowCopyPaste ;
itemcopy . Enabled = ( General . Map ! = null ) & & ( General . Editing . Mode ! = null ) & & General . Editing . Mode . Attributes . AllowCopyPaste ;
itempaste . Enabled = ( General . Map ! = null ) & & ( General . Editing . Mode ! = null ) & & General . Editing . Mode . Attributes . AllowCopyPaste ;
2009-07-09 14:03:47 +00:00
itempastespecial . Enabled = ( General . Map ! = null ) & & ( General . Editing . Mode ! = null ) & & General . Editing . Mode . Attributes . AllowCopyPaste ;
2016-06-15 22:02:51 +00:00
itemsplitjoinedsectors . Checked = General . Settings . SplitJoinedSectors ; //mxd
2014-01-08 09:46:57 +00:00
itemautoclearsidetextures . Checked = General . Settings . AutoClearSidedefTextures ; //mxd
2015-08-23 23:32:12 +00:00
itemdynamicgridsize . Enabled = ( General . Map ! = null ) ; //mxd
itemdynamicgridsize . Checked = General . Settings . DynamicGridSize ; //mxd
2009-04-19 18:07:22 +00:00
// Determine undo description
if ( itemundo . Enabled )
itemundo . Text = "Undo " + General . Map . UndoRedo . NextUndo . Description ;
else
itemundo . Text = "Undo" ;
// Determine redo description
if ( itemredo . Enabled )
itemredo . Text = "Redo " + General . Map . UndoRedo . NextRedo . Description ;
else
itemredo . Text = "Redo" ;
// Toolbar icons
buttonundo . Enabled = itemundo . Enabled ;
buttonredo . Enabled = itemredo . Enabled ;
buttonundo . ToolTipText = itemundo . Text ;
buttonredo . ToolTipText = itemredo . Text ;
2014-01-08 09:46:57 +00:00
buttonautoclearsidetextures . Checked = itemautoclearsidetextures . Checked ; //mxd
2009-04-19 18:07:22 +00:00
buttoncut . Enabled = itemcut . Enabled ;
buttoncopy . Enabled = itemcopy . Enabled ;
buttonpaste . Enabled = itempaste . Enabled ;
2016-06-02 09:55:01 +00:00
//mxd. Geometry merge mode items
if ( General . Map ! = null )
{
for ( int i = 0 ; i < geomergemodesbuttons . Length ; i + + )
{
// Check the correct item
geomergemodesbuttons [ i ] . Checked = ( i = = ( int ) General . Settings . MergeGeometryMode ) ;
geomergemodesitems [ i ] . Checked = ( i = = ( int ) General . Settings . MergeGeometryMode ) ;
}
}
2009-04-19 18:07:22 +00:00
}
2013-04-01 11:06:01 +00:00
//mxd
2014-07-16 09:45:04 +00:00
private void menuedit_DropDownOpening ( object sender , EventArgs e )
{
2015-12-28 15:01:53 +00:00
if ( General . Map = = null )
2014-07-16 09:45:04 +00:00
{
selectGroup . Enabled = false ;
clearGroup . Enabled = false ;
addToGroup . Enabled = false ;
return ;
}
2013-04-01 11:06:01 +00:00
2014-07-16 09:45:04 +00:00
//get data
ToolStripItem item ;
GroupInfo [ ] infos = new GroupInfo [ 10 ] ;
for ( int i = 0 ; i < infos . Length ; i + + ) infos [ i ] = General . Map . Map . GetGroupInfo ( i ) ;
//update "Add to group" menu
addToGroup . Enabled = true ;
addToGroup . DropDownItems . Clear ( ) ;
2015-12-28 15:01:53 +00:00
foreach ( GroupInfo gi in infos )
2014-07-16 09:45:04 +00:00
{
item = addToGroup . DropDownItems . Add ( gi . ToString ( ) ) ;
item . Tag = "builder_assigngroup" + gi . Index ;
item . Click + = InvokeTaggedAction ;
2013-04-01 11:06:01 +00:00
}
2014-07-16 09:45:04 +00:00
//update "Select group" menu
selectGroup . DropDownItems . Clear ( ) ;
2015-12-28 15:01:53 +00:00
foreach ( GroupInfo gi in infos )
2014-12-03 23:15:26 +00:00
{
2014-07-16 09:45:04 +00:00
if ( gi . Empty ) continue ;
item = selectGroup . DropDownItems . Add ( gi . ToString ( ) ) ;
item . Tag = "builder_selectgroup" + gi . Index ;
item . Click + = InvokeTaggedAction ;
}
//update "Clear group" menu
clearGroup . DropDownItems . Clear ( ) ;
2014-12-03 23:15:26 +00:00
foreach ( GroupInfo gi in infos )
{
2014-07-16 09:45:04 +00:00
if ( gi . Empty ) continue ;
item = clearGroup . DropDownItems . Add ( gi . ToString ( ) ) ;
item . Tag = "builder_cleargroup" + gi . Index ;
item . Click + = InvokeTaggedAction ;
}
selectGroup . Enabled = selectGroup . DropDownItems . Count > 0 ;
clearGroup . Enabled = clearGroup . DropDownItems . Count > 0 ;
2013-04-01 11:06:01 +00:00
}
2015-07-14 23:34:31 +00:00
//mxd. Action to toggle comments rendering
[BeginAction("togglecomments")]
internal void ToggleComments ( )
{
buttontogglecomments . Checked = ! buttontogglecomments . Checked ;
itemtogglecomments . Checked = buttontogglecomments . Checked ;
General . Settings . RenderComments = buttontogglecomments . Checked ;
DisplayStatus ( StatusType . Action , "Comment icons are " + ( buttontogglecomments . Checked ? "SHOWN" : "HIDDEN" ) ) ;
// Redraw display to show changes
RedrawDisplay ( ) ;
}
2016-02-22 15:20:08 +00:00
//mxd. Action to toggle fixed things scale
[BeginAction("togglefixedthingsscale")]
internal void ToggleFixedThingsScale ( )
{
buttontogglefixedthingsscale . Checked = ! buttontogglefixedthingsscale . Checked ;
itemtogglefixedthingsscale . Checked = buttontogglefixedthingsscale . Checked ;
General . Settings . FixedThingsScale = buttontogglefixedthingsscale . Checked ;
DisplayStatus ( StatusType . Action , "Fixed things scale is " + ( buttontogglefixedthingsscale . Checked ? "ENABLED" : "DISABLED" ) ) ;
// Redraw display to show changes
RedrawDisplay ( ) ;
}
2009-04-19 18:07:22 +00:00
// Action to toggle snap to grid
[BeginAction("togglesnap")]
internal void ToggleSnapToGrid ( )
{
buttonsnaptogrid . Checked = ! buttonsnaptogrid . Checked ;
itemsnaptogrid . Checked = buttonsnaptogrid . Checked ;
2014-01-08 09:46:57 +00:00
DisplayStatus ( StatusType . Action , "Snap to grid is " + ( buttonsnaptogrid . Checked ? "ENABLED" : "DISABLED" ) ) ;
2009-04-19 18:07:22 +00:00
}
// Action to toggle auto merge
[BeginAction("toggleautomerge")]
internal void ToggleAutoMerge ( )
{
buttonautomerge . Checked = ! buttonautomerge . Checked ;
itemautomerge . Checked = buttonautomerge . Checked ;
2014-01-08 09:46:57 +00:00
DisplayStatus ( StatusType . Action , "Snap to geometry is " + ( buttonautomerge . Checked ? "ENABLED" : "DISABLED" ) ) ;
}
2016-06-15 22:02:51 +00:00
//mxd
[BeginAction("togglejoinedsectorssplitting")]
internal void ToggleJoinedSectorsSplitting ( )
{
buttonsplitjoinedsectors . Checked = ! buttonsplitjoinedsectors . Checked ;
itemsplitjoinedsectors . Checked = buttonsplitjoinedsectors . Checked ;
General . Settings . SplitJoinedSectors = buttonsplitjoinedsectors . Checked ;
DisplayStatus ( StatusType . Action , "Joined sectors splitting is " + ( General . Settings . SplitJoinedSectors ? "ENABLED" : "DISABLED" ) ) ;
}
2014-03-03 09:52:55 +00:00
//mxd
[BeginAction("togglebrightness")]
2014-12-03 23:15:26 +00:00
internal void ToggleBrightness ( )
{
2014-03-03 09:52:55 +00:00
Renderer . FullBrightness = ! Renderer . FullBrightness ;
buttonfullbrightness . Checked = Renderer . FullBrightness ;
2015-08-23 23:32:12 +00:00
itemfullbrightness . Checked = Renderer . FullBrightness ;
2014-03-03 09:52:55 +00:00
General . Interface . DisplayStatus ( StatusType . Action , "Full Brightness is now " + ( Renderer . FullBrightness ? "ON" : "OFF" ) ) ;
// Redraw display to show changes
General . Interface . RedrawDisplay ( ) ;
}
2015-08-04 23:28:02 +00:00
//mxd
[BeginAction("togglegrid")]
protected void ToggleGrid ( )
{
General . Settings . RenderGrid = ! General . Settings . RenderGrid ;
2015-08-23 23:32:12 +00:00
itemtogglegrid . Checked = General . Settings . RenderGrid ;
2015-08-04 23:28:02 +00:00
buttontogglegrid . Checked = General . Settings . RenderGrid ;
General . Interface . DisplayStatus ( StatusType . Action , "Grid rendering is " + ( General . Settings . RenderGrid ? "ENABLED" : "DISABLED" ) ) ;
// Redraw display to show changes
General . Map . CRenderer2D . GridVisibilityChanged ( ) ;
General . Interface . RedrawDisplay ( ) ;
}
2019-01-14 18:07:08 +00:00
[BeginAction("aligngridtolinedef")]
protected void AlignGridToLinedef ( )
{
2021-03-14 15:40:55 +00:00
if ( General . Map = = null )
return ;
2019-01-14 18:07:08 +00:00
if ( General . Map . Map . SelectedLinedefsCount ! = 1 )
{
2019-01-16 06:44:38 +00:00
General . Interface . DisplayStatus ( StatusType . Warning , "Exactly one linedef must be selected" ) ;
General . Interface . MessageBeep ( MessageBeepType . Warning ) ;
2019-01-14 18:07:08 +00:00
return ;
}
Linedef line = General . Map . Map . SelectedLinedefs . First . Value ;
Vertex vertex = line . Start ;
General . Map . Grid . SetGridRotation ( line . Angle ) ;
General . Map . Grid . SetGridOrigin ( vertex . Position . x , vertex . Position . y ) ;
General . Map . CRenderer2D . GridVisibilityChanged ( ) ;
General . Interface . RedrawDisplay ( ) ;
}
[BeginAction("setgridorigintovertex")]
protected void SetGridOriginToVertex ( )
{
2021-03-14 15:40:55 +00:00
if ( General . Map = = null )
return ;
2019-01-14 18:07:08 +00:00
if ( General . Map . Map . SelectedVerticessCount ! = 1 )
{
2019-01-16 06:44:38 +00:00
General . Interface . DisplayStatus ( StatusType . Warning , "Exactly one vertex must be selected" ) ;
General . Interface . MessageBeep ( MessageBeepType . Warning ) ;
2019-01-14 18:07:08 +00:00
return ;
}
Vertex vertex = General . Map . Map . SelectedVertices . First . Value ;
General . Map . Grid . SetGridOrigin ( vertex . Position . x , vertex . Position . y ) ;
General . Map . CRenderer2D . GridVisibilityChanged ( ) ;
General . Interface . RedrawDisplay ( ) ;
}
[BeginAction("resetgrid")]
protected void ResetGrid ( )
{
General . Map . Grid . SetGridRotation ( 0.0f ) ;
General . Map . Grid . SetGridOrigin ( 0 , 0 ) ;
General . Map . CRenderer2D . GridVisibilityChanged ( ) ;
General . Interface . RedrawDisplay ( ) ;
}
2015-08-04 23:28:02 +00:00
2015-08-20 14:09:28 +00:00
//mxd
[BeginAction("toggledynamicgrid")]
protected void ToggleDynamicGrid ( )
{
General . Settings . DynamicGridSize = ! General . Settings . DynamicGridSize ;
2015-08-23 23:32:12 +00:00
itemdynamicgridsize . Checked = General . Settings . DynamicGridSize ;
2015-08-20 14:09:28 +00:00
buttontoggledynamicgrid . Checked = General . Settings . DynamicGridSize ;
General . Interface . DisplayStatus ( StatusType . Action , "Dynamic grid size is " + ( General . Settings . DynamicGridSize ? "ENABLED" : "DISABLED" ) ) ;
// Redraw display to show changes
if ( General . Editing . Mode is ClassicMode ) ( ( ClassicMode ) General . Editing . Mode ) . MatchGridSizeToDisplayScale ( ) ;
General . Interface . RedrawDisplay ( ) ;
}
2014-01-08 09:46:57 +00:00
//mxd
[BeginAction("toggleautoclearsidetextures")]
2014-12-03 23:15:26 +00:00
internal void ToggleAutoClearSideTextures ( )
{
2014-01-08 09:46:57 +00:00
buttonautoclearsidetextures . Checked = ! buttonautoclearsidetextures . Checked ;
itemautoclearsidetextures . Checked = buttonautoclearsidetextures . Checked ;
General . Settings . AutoClearSidedefTextures = buttonautoclearsidetextures . Checked ;
DisplayStatus ( StatusType . Action , "Auto removal of unused sidedef textures is " + ( buttonautoclearsidetextures . Checked ? "ENABLED" : "DISABLED" ) ) ;
2009-04-19 18:07:22 +00:00
}
2013-03-18 13:52:27 +00:00
//mxd
[BeginAction("viewusedtags")]
2014-12-03 23:15:26 +00:00
internal void ViewUsedTags ( )
{
2013-03-18 13:52:27 +00:00
TagStatisticsForm f = new TagStatisticsForm ( ) ;
f . ShowDialog ( this ) ;
}
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
//mxd
[BeginAction("viewthingtypes")]
internal void ViewThingTypes ( )
{
ThingStatisticsForm f = new ThingStatisticsForm ( ) ;
f . ShowDialog ( this ) ;
}
2016-06-02 09:55:01 +00:00
//mxd
[BeginAction("geomergeclassic")]
private void GeoMergeClassic ( )
{
General . Settings . MergeGeometryMode = MergeGeometryMode . CLASSIC ;
UpdateToolbar ( ) ;
UpdateEditMenu ( ) ;
DisplayStatus ( StatusType . Action , "\"Merge Dragged Vertices Only\" mode selected" ) ;
}
//mxd
[BeginAction("geomerge")]
private void GeoMerge ( )
{
General . Settings . MergeGeometryMode = MergeGeometryMode . MERGE ;
UpdateToolbar ( ) ;
UpdateEditMenu ( ) ;
DisplayStatus ( StatusType . Action , "\"Merge Dragged Geometry\" mode selected" ) ;
}
//mxd
[BeginAction("georeplace")]
private void GeoReplace ( )
{
General . Settings . MergeGeometryMode = MergeGeometryMode . REPLACE ;
UpdateToolbar ( ) ;
UpdateEditMenu ( ) ;
DisplayStatus ( StatusType . Action , "\"Replace with Dragged Geometry\" mode selected" ) ;
}
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = View Menu
2016-09-07 15:15:07 +00:00
// This sets up the View menu
2009-04-19 18:07:22 +00:00
private void UpdateViewMenu ( )
{
2015-08-23 23:32:12 +00:00
menuview . Visible = ( General . Map ! = null ) ; //mxd
2009-04-19 18:07:22 +00:00
// Menu items
Added, Visual mode, GLDEFS, GLOOME: subtractive glow is now supported.
Changed, Visual mode: changed thing fog calculation logic. Should be closer to GZDoom now.
Fixed, GLDEFS parser: "height" texture parameter was not treated as optional.
Fixed, text lump parsers: in some cases incorrect line number was displayed in error and warning messages.
Fixed, Visual mode: glow effect was not applied to sectors with 3 sidedefs.
Fixed, Visual mode: in some cases glow effect was not updated when replacing textures.
Fixed, general interface: "Full Brightness" button state was not updated during map loading.
Fixed, Drag Linedefs/Vertices/Sectors/Things modes: positions of line length labels were not updated while panning the view.
Cosmetic: added a bunch of new icons.
Cosmetic: changed Visual mode crosshair.
2015-08-27 20:46:49 +00:00
itemfullbrightness . Checked = Renderer . FullBrightness ; //mxd
2015-08-23 23:32:12 +00:00
itemtogglegrid . Checked = General . Settings . RenderGrid ; //mxd
2009-04-19 18:07:22 +00:00
itemtoggleinfo . Checked = IsInfoPanelExpanded ;
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
itemtogglecomments . Visible = ( General . Map ! = null & & General . Map . UDMF ) ; //mxd
2015-07-14 23:34:31 +00:00
itemtogglecomments . Checked = General . Settings . RenderComments ; //mxd
2016-02-22 15:20:08 +00:00
itemtogglefixedthingsscale . Visible = ( General . Map ! = null ) ; //mxd
itemtogglefixedthingsscale . Checked = General . Settings . FixedThingsScale ; //mxd
2016-09-07 15:15:07 +00:00
itemtogglefog . Checked = General . Settings . GZDrawFog ;
itemtogglesky . Checked = General . Settings . GZDrawSky ;
itemtoggleeventlines . Checked = General . Settings . GZShowEventLines ;
itemtogglevisualverts . Visible = ( General . Map ! = null & & General . Map . UDMF ) ;
itemtogglevisualverts . Checked = General . Settings . GZShowVisualVertices ;
// Update Model Rendering Mode items...
foreach ( ToolStripMenuItem item in itemmodelmodes . DropDownItems )
{
item . Checked = ( ( ModelRenderMode ) item . Tag = = General . Settings . GZDrawModelsMode ) ;
if ( item . Checked ) itemmodelmodes . Image = item . Image ;
}
// Update Dynamic Light Mode items...
foreach ( ToolStripMenuItem item in itemdynlightmodes . DropDownItems )
{
item . Checked = ( ( LightRenderMode ) item . Tag = = General . Settings . GZDrawLightsMode ) ;
if ( item . Checked ) itemdynlightmodes . Image = item . Image ;
}
2009-04-19 18:07:22 +00:00
// View mode items
2015-08-23 23:32:12 +00:00
if ( General . Map ! = null )
2009-04-19 18:07:22 +00:00
{
2015-08-23 23:32:12 +00:00
for ( int i = 0 ; i < Renderer2D . NUM_VIEW_MODES ; i + + )
2009-04-19 18:07:22 +00:00
{
// Check the correct item
viewmodesbuttons [ i ] . Checked = ( i = = ( int ) General . Map . CRenderer2D . ViewMode ) ;
viewmodesitems [ i ] . Checked = ( i = = ( int ) General . Map . CRenderer2D . ViewMode ) ;
}
}
}
2016-09-07 15:15:07 +00:00
//mxd
[BeginAction("gztoggleenhancedrendering")]
public void ToggleEnhancedRendering ( )
{
General . Settings . EnhancedRenderingEffects = ! General . Settings . EnhancedRenderingEffects ;
General . Settings . GZDrawFog = General . Settings . EnhancedRenderingEffects ;
General . Settings . GZDrawSky = General . Settings . EnhancedRenderingEffects ;
General . Settings . GZDrawLightsMode = ( General . Settings . EnhancedRenderingEffects ? LightRenderMode . ALL : LightRenderMode . NONE ) ;
General . Settings . GZDrawModelsMode = ( General . Settings . EnhancedRenderingEffects ? ModelRenderMode . ALL : ModelRenderMode . NONE ) ;
UpdateGZDoomPanel ( ) ;
UpdateViewMenu ( ) ;
DisplayStatus ( StatusType . Info , "Enhanced rendering effects are " + ( General . Settings . EnhancedRenderingEffects ? "ENABLED" : "DISABLED" ) ) ;
}
//mxd
[BeginAction("gztogglefog")]
internal void ToggleFog ( )
{
General . Settings . GZDrawFog = ! General . Settings . GZDrawFog ;
itemtogglefog . Checked = General . Settings . GZDrawFog ;
buttontogglefog . Checked = General . Settings . GZDrawFog ;
General . MainWindow . DisplayStatus ( StatusType . Action , "Fog rendering is " + ( General . Settings . GZDrawFog ? "ENABLED" : "DISABLED" ) ) ;
General . MainWindow . RedrawDisplay ( ) ;
General . MainWindow . UpdateGZDoomPanel ( ) ;
}
//mxd
[BeginAction("gztogglesky")]
internal void ToggleSky ( )
{
General . Settings . GZDrawSky = ! General . Settings . GZDrawSky ;
itemtogglesky . Checked = General . Settings . GZDrawSky ;
buttontogglesky . Checked = General . Settings . GZDrawSky ;
General . MainWindow . DisplayStatus ( StatusType . Action , "Sky rendering is " + ( General . Settings . GZDrawSky ? "ENABLED" : "DISABLED" ) ) ;
General . MainWindow . RedrawDisplay ( ) ;
General . MainWindow . UpdateGZDoomPanel ( ) ;
}
[BeginAction("gztoggleeventlines")]
internal void ToggleEventLines ( )
{
General . Settings . GZShowEventLines = ! General . Settings . GZShowEventLines ;
itemtoggleeventlines . Checked = General . Settings . GZShowEventLines ;
buttontoggleeventlines . Checked = General . Settings . GZShowEventLines ;
General . MainWindow . DisplayStatus ( StatusType . Action , "Event lines are " + ( General . Settings . GZShowEventLines ? "ENABLED" : "DISABLED" ) ) ;
General . MainWindow . RedrawDisplay ( ) ;
General . MainWindow . UpdateGZDoomPanel ( ) ;
}
[BeginAction("gztogglevisualvertices")]
internal void ToggleVisualVertices ( )
{
General . Settings . GZShowVisualVertices = ! General . Settings . GZShowVisualVertices ;
itemtogglevisualverts . Checked = General . Settings . GZShowVisualVertices ;
buttontogglevisualvertices . Checked = General . Settings . GZShowVisualVertices ;
General . MainWindow . DisplayStatus ( StatusType . Action , "Visual vertices are " + ( General . Settings . GZShowVisualVertices ? "ENABLED" : "DISABLED" ) ) ;
General . MainWindow . RedrawDisplay ( ) ;
General . MainWindow . UpdateGZDoomPanel ( ) ;
}
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Mode Menu
// This sets up the modes menu
private void UpdateModeMenu ( )
{
menumode . Visible = ( General . Map ! = null ) ;
}
#endregion
#region = = = = = = = = = = = = = = = = = = Help Menu
// This sets up the help menu
private void UpdateHelpMenu ( )
{
2015-10-23 12:29:35 +00:00
itemhelpeditmode . Visible = ( General . Map ! = null ) ; //mxd
itemhelpeditmode . Enabled = ( General . Map ! = null & & General . Editing . Mode ! = null ) ;
2009-04-19 18:07:22 +00:00
}
2015-07-01 23:09:34 +00:00
//mxd. Check updates clicked
private void itemhelpcheckupdates_Click ( object sender , EventArgs e )
{
2019-12-24 21:32:37 +00:00
UpdateChecker . PerformCheck ( true ) ;
2015-07-01 23:09:34 +00:00
}
2016-12-27 10:12:10 +00:00
//mxd. Github issues clicked
private void itemhelpissues_Click ( object sender , EventArgs e )
{
2017-01-15 04:30:53 +00:00
General . OpenWebsite ( "https://github.com/jewalky/GZDoom-Builder-Bugfix/issues" ) ;
2016-12-27 10:12:10 +00:00
}
2009-04-19 18:07:22 +00:00
// About clicked
private void itemhelpabout_Click ( object sender , EventArgs e )
{
// Show about dialog
2015-03-05 23:19:10 +00:00
AboutForm aboutform = new AboutForm ( ) ;
2009-04-19 18:07:22 +00:00
aboutform . ShowDialog ( this ) ;
}
// Reference Manual clicked
private void itemhelprefmanual_Click ( object sender , EventArgs e )
{
General . ShowHelp ( "introduction.html" ) ;
}
// About this Editing Mode
private void itemhelpeditmode_Click ( object sender , EventArgs e )
{
if ( ( General . Map ! = null ) & & ( General . Editing . Mode ! = null ) )
General . Editing . Mode . OnHelp ( ) ;
}
2013-06-10 14:04:23 +00:00
//mxd
2014-12-03 23:15:26 +00:00
private void itemShortcutReference_Click ( object sender , EventArgs e )
{
2014-01-13 09:51:23 +00:00
const string columnLabels = "<tr><td width=\"240px;\"><strong>Action</strong></td><td width=\"120px;\"><div align=\"center\"><strong>Shortcut</strong></div></td><td width=\"120px;\"><div align=\"center\"><strong>Modifiers</strong></div></td><td><strong>Description</strong></td></tr>" ;
const string categoryPadding = "<tr><td colspan=\"4\"></td></tr>" ;
const string categoryStart = "<tr><td colspan=\"4\" bgcolor=\"#333333\"><strong style=\"color:#FFFFFF\">" ;
const string categoryEnd = "</strong><div style=\"text-align:right; float:right\"><a style=\"color:#FFFFFF\" href=\"#top\">[to top]</a></div></td></tr>" ;
const string fileName = "GZDB Actions Reference.html" ;
2014-01-13 08:06:56 +00:00
Actions . Action [ ] actions = General . Actions . GetAllActions ( ) ;
2014-02-26 14:11:06 +00:00
Dictionary < string , List < Actions . Action > > sortedActions = new Dictionary < string , List < Actions . Action > > ( StringComparer . Ordinal ) ;
2013-06-10 14:04:23 +00:00
2014-12-03 23:15:26 +00:00
foreach ( Actions . Action action in actions )
{
2013-06-10 14:04:23 +00:00
if ( ! sortedActions . ContainsKey ( action . Category ) )
2014-01-13 08:06:56 +00:00
sortedActions . Add ( action . Category , new List < Actions . Action > ( ) ) ;
2013-06-10 14:04:23 +00:00
sortedActions [ action . Category ] . Add ( action ) ;
}
System . Text . StringBuilder html = new System . Text . StringBuilder ( ) ;
//head
2014-01-13 09:51:23 +00:00
html . AppendLine ( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" + Environment . NewLine +
"<html xmlns=\"http://www.w3.org/1999/xhtml\">" + Environment . NewLine +
"<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>GZDoom Builder Actions Reference</title></head>" + Environment . NewLine +
"<body bgcolor=\"#666666\">" + Environment . NewLine +
"<div style=\"padding-left:60px; padding-right:60px; padding-top:20px; padding-bottom:20px;\">" + Environment . NewLine ) ;
//table header
html . AppendLine ( "<table bgcolor=\"#FFFFFF\" width=\"100%\" border=\"0\" cellspacing=\"6\" cellpadding=\"6\" style=\"font-family: 'Trebuchet MS',georgia,Verdana,Sans-serif;\">" + Environment . NewLine +
"<tr><td colspan=\"4\" bgcolor=\"#333333\"><span style=\"font-size: 24px\"><a name=\"top\" id=\"top\"></a><strong style=\"color:#FFFFFF\">GZDoom Builder Actions Reference</strong></span></td></tr>" ) ;
//categories navigator
List < string > catnames = new List < string > ( sortedActions . Count ) ;
int counter = 0 ;
int numActions = 0 ;
2014-12-03 23:15:26 +00:00
foreach ( KeyValuePair < string , List < Actions . Action > > category in sortedActions )
{
2014-01-13 09:51:23 +00:00
catnames . Add ( "<a href=\"#cat" + ( counter + + ) + "\">" + General . Actions . Categories [ category . Key ] + "</a>" ) ;
numActions + = category . Value . Count ;
}
html . AppendLine ( "<tr><td colspan=\"4\"><strong>Total number of actions:</strong> " + numActions + "<br/><strong>Jump to:</strong> " ) ;
html . AppendLine ( string . Join ( " | " , catnames . ToArray ( ) ) ) ;
html . AppendLine ( "</td></tr>" + Environment . NewLine ) ;
2013-06-10 14:04:23 +00:00
//add descriptions
2014-01-13 09:51:23 +00:00
counter = 0 ;
2014-12-03 23:15:26 +00:00
foreach ( KeyValuePair < string , List < Actions . Action > > category in sortedActions )
{
2013-06-10 14:04:23 +00:00
//add category title
html . AppendLine ( categoryPadding ) ;
2014-01-13 09:51:23 +00:00
html . AppendLine ( categoryStart + "<a name=\"cat" + counter + "\" id=\"cat" + counter + "\"></a>" + General . Actions . Categories [ category . Key ] + categoryEnd ) ;
2013-06-10 14:04:23 +00:00
html . AppendLine ( columnLabels ) ;
2014-01-13 09:51:23 +00:00
counter + + ;
2013-06-10 14:04:23 +00:00
2014-02-26 14:11:06 +00:00
Dictionary < string , Actions . Action > actionsByTitle = new Dictionary < string , Actions . Action > ( StringComparer . Ordinal ) ;
2013-06-10 14:04:23 +00:00
List < string > actionTitles = new List < string > ( ) ;
2014-12-03 23:15:26 +00:00
foreach ( Actions . Action action in category . Value )
{
2013-06-10 14:04:23 +00:00
actionsByTitle . Add ( action . Title , action ) ;
actionTitles . Add ( action . Title ) ;
}
actionTitles . Sort ( ) ;
2014-12-03 23:15:26 +00:00
foreach ( string title in actionTitles )
{
2015-12-28 15:01:53 +00:00
Actions . Action a = actionsByTitle [ title ] ;
2013-06-10 14:04:23 +00:00
List < string > modifiers = new List < string > ( ) ;
html . AppendLine ( "<tr>" ) ;
html . AppendLine ( "<td>" + title + "</td>" ) ;
html . AppendLine ( "<td><div align=\"center\">" + Actions . Action . GetShortcutKeyDesc ( a . ShortcutKey ) + "</div></td>" ) ;
if ( a . DisregardControl ) modifiers . Add ( "Ctrl" ) ;
2014-01-13 08:06:56 +00:00
if ( a . DisregardAlt ) modifiers . Add ( "Alt" ) ;
2013-06-10 14:04:23 +00:00
if ( a . DisregardShift ) modifiers . Add ( "Shift" ) ;
html . AppendLine ( "<td><div align=\"center\">" + string . Join ( ", " , modifiers . ToArray ( ) ) + "</div></td>" ) ;
html . AppendLine ( "<td>" + a . Description + "</td>" ) ;
html . AppendLine ( "</tr>" ) ;
}
}
//add bottom
html . AppendLine ( "</table></div></body></html>" ) ;
//write
2014-09-08 13:09:14 +00:00
string path ;
2014-12-03 23:15:26 +00:00
try
{
2014-09-08 13:09:14 +00:00
path = Path . Combine ( General . AppPath , fileName ) ;
2014-12-03 23:15:26 +00:00
using ( StreamWriter writer = File . CreateText ( path ) )
{
2014-09-08 13:09:14 +00:00
writer . Write ( html . ToString ( ) ) ;
}
2014-12-03 23:15:26 +00:00
}
2016-02-01 22:04:00 +00:00
catch ( Exception )
2014-12-03 23:15:26 +00:00
{
2014-09-08 13:09:14 +00:00
//Configurtions path SHOULD be accessible and not read-only, right?
path = Path . Combine ( General . SettingsPath , fileName ) ;
2014-12-03 23:15:26 +00:00
using ( StreamWriter writer = File . CreateText ( path ) )
{
2014-09-08 13:09:14 +00:00
writer . Write ( html . ToString ( ) ) ;
}
2013-06-10 14:04:23 +00:00
}
//open file
2016-03-08 20:41:06 +00:00
DisplayStatus ( StatusType . Info , "Shortcut reference saved to \"" + path + "\"" ) ;
2015-07-14 23:34:31 +00:00
Process . Start ( path ) ;
2013-06-10 14:04:23 +00:00
}
2015-10-02 23:15:29 +00:00
//mxd
private void itemopenconfigfolder_Click ( object sender , EventArgs e )
{
if ( Directory . Exists ( General . SettingsPath ) ) Process . Start ( General . SettingsPath ) ;
2016-03-08 20:41:06 +00:00
else General . ShowErrorMessage ( "Huh? Where did Settings folder go?.." + Environment . NewLine
+ "I swear it was here: \"" + General . SettingsPath + "\"!" , MessageBoxButtons . OK ) ; // I don't think this will ever happen
2015-10-02 23:15:29 +00:00
}
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Prefabs Menu
// This sets up the prefabs menu
private void UpdatePrefabsMenu ( )
{
2015-08-23 23:32:12 +00:00
menuprefabs . Visible = ( General . Map ! = null ) ; //mxd
2009-04-19 18:07:22 +00:00
// Enable/disable items
2011-12-03 14:49:53 +00:00
itemcreateprefab . Enabled = ( General . Map ! = null ) & & ( General . Editing . Mode ! = null ) & & General . Editing . Mode . Attributes . AllowCopyPaste ;
iteminsertprefabfile . Enabled = ( General . Map ! = null ) & & ( General . Editing . Mode ! = null ) & & General . Editing . Mode . Attributes . AllowCopyPaste ;
iteminsertpreviousprefab . Enabled = ( General . Map ! = null ) & & ( General . Editing . Mode ! = null ) & & General . Map . CopyPaste . IsPreviousPrefabAvailable & & General . Editing . Mode . Attributes . AllowCopyPaste ;
2009-04-19 18:07:22 +00:00
// Toolbar icons
2011-12-03 14:49:53 +00:00
buttoninsertprefabfile . Enabled = iteminsertprefabfile . Enabled ;
buttoninsertpreviousprefab . Enabled = iteminsertpreviousprefab . Enabled ;
2009-04-19 18:07:22 +00:00
}
#endregion
#region = = = = = = = = = = = = = = = = = = Tools Menu
// This sets up the tools menu
private void UpdateToolsMenu ( )
{
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
//mxd. Enable/disable items
2013-09-11 09:47:53 +00:00
bool enabled = ( General . Map ! = null ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
itemreloadresources . Visible = enabled ;
seperatortoolsconfig . Visible = enabled ;
itemsavescreenshot . Visible = enabled ;
itemsaveeditareascreenshot . Visible = enabled ;
separatortoolsscreenshots . Visible = enabled ;
itemtestmap . Visible = enabled ;
bool supported = ( enabled & & ! string . IsNullOrEmpty ( General . Map . Config . DecorateGames ) ) ;
itemReloadGldefs . Visible = supported ;
itemReloadModedef . Visible = supported ;
2009-04-19 18:07:22 +00:00
}
// Errors and Warnings
[BeginAction("showerrors")]
internal void ShowErrors ( )
{
ErrorsForm errform = new ErrorsForm ( ) ;
errform . ShowDialog ( this ) ;
errform . Dispose ( ) ;
2013-09-11 09:47:53 +00:00
//mxd
2013-11-29 12:24:47 +00:00
SetWarningsCount ( General . ErrorLogger . ErrorsCount , false ) ;
2009-04-19 18:07:22 +00:00
}
// Game Configuration action
[BeginAction("configuration")]
internal void ShowConfiguration ( )
{
// Show configuration dialog
ShowConfigurationPage ( - 1 ) ;
}
// This shows the configuration on a specific page
internal void ShowConfigurationPage ( int pageindex )
{
// Show configuration dialog
ConfigForm cfgform = new ConfigForm ( ) ;
if ( pageindex > - 1 ) cfgform . ShowTab ( pageindex ) ;
if ( cfgform . ShowDialog ( this ) = = DialogResult . OK )
{
2009-07-09 15:15:49 +00:00
// Update stuff
2009-07-21 18:48:00 +00:00
SetupInterface ( ) ;
2009-04-19 18:07:22 +00:00
UpdateInterface ( ) ;
2017-02-07 18:02:31 +00:00
General . Editing . UpdateCurrentEditModes ( ) ;
2009-04-19 18:07:22 +00:00
General . Plugins . ProgramReconfigure ( ) ;
2021-04-02 10:13:22 +00:00
// Save program configuration
General . SaveSettings ( ) ;
2009-04-19 18:07:22 +00:00
// Reload resources if a map is open
2021-04-02 10:13:22 +00:00
if ( ( General . Map ! = null ) & & cfgform . ReloadResources ) General . Actions . InvokeAction ( "builder_reloadresources" ) ;
2009-07-09 15:15:49 +00:00
2009-04-19 18:07:22 +00:00
// Redraw display
RedrawDisplay ( ) ;
}
// Done
cfgform . Dispose ( ) ;
}
// Preferences action
[BeginAction("preferences")]
internal void ShowPreferences ( )
{
// Show preferences dialog
PreferencesForm prefform = new PreferencesForm ( ) ;
if ( prefform . ShowDialog ( this ) = = DialogResult . OK )
{
2009-07-09 15:15:49 +00:00
// Update stuff
2009-07-21 18:48:00 +00:00
SetupInterface ( ) ;
2010-08-15 13:45:43 +00:00
UpdateInterface ( ) ;
2017-02-07 18:02:31 +00:00
ApplyShortcutKeys ( ) ;
2009-04-19 18:07:22 +00:00
General . Colors . CreateCorrectionTable ( ) ;
General . Plugins . ProgramReconfigure ( ) ;
2021-04-02 10:13:22 +00:00
// Save program configuration
General . SaveSettings ( ) ;
2009-07-09 15:15:49 +00:00
2009-04-19 18:07:22 +00:00
// Map opened?
if ( General . Map ! = null )
{
// Reload resources!
if ( General . Map . ScriptEditor ! = null ) General . Map . ScriptEditor . Editor . RefreshSettings ( ) ;
General . Map . Graphics . SetupSettings ( ) ;
General . Map . UpdateConfiguration ( ) ;
2009-05-13 22:35:34 +00:00
if ( prefform . ReloadResources ) General . Actions . InvokeAction ( "builder_reloadresources" ) ;
2009-04-19 18:07:22 +00:00
}
// Redraw display
RedrawDisplay ( ) ;
}
// Done
prefform . Dispose ( ) ;
}
2013-06-05 08:08:56 +00:00
//mxd
2014-10-22 13:07:17 +00:00
internal void SaveScreenshot ( bool activeControlOnly )
{
2014-08-07 10:20:35 +00:00
//pick a valid folder
string folder = General . Settings . ScreenshotsPath ;
2015-12-28 15:01:53 +00:00
if ( ! Directory . Exists ( folder ) )
2014-10-22 13:07:17 +00:00
{
2016-03-08 20:41:06 +00:00
if ( folder ! = General . DefaultScreenshotsPath
& & General . ShowErrorMessage ( "Screenshots save path \"" + folder
+ "\" does not exist!\nPress OK to save to the default folder (\""
+ General . DefaultScreenshotsPath
+ "\").\nPress Cancel to abort." , MessageBoxButtons . OKCancel ) = = DialogResult . Cancel ) return ;
2014-08-07 10:20:35 +00:00
folder = General . DefaultScreenshotsPath ;
if ( ! Directory . Exists ( folder ) ) Directory . CreateDirectory ( folder ) ;
}
2013-06-05 08:08:56 +00:00
2014-10-22 13:07:17 +00:00
// Create name and bounds
2013-06-05 08:08:56 +00:00
string name ;
Rectangle bounds ;
2014-10-22 13:07:17 +00:00
bool displayextrainfo = false ;
string mapname = ( General . Map ! = null ? Path . GetFileNameWithoutExtension ( General . Map . FileTitle ) : General . ThisAssembly . GetName ( ) . Name ) ;
if ( activeControlOnly )
{
2015-12-28 15:01:53 +00:00
if ( Form . ActiveForm ! = null & & Form . ActiveForm ! = this )
2014-10-22 13:07:17 +00:00
{
2014-10-31 07:42:53 +00:00
name = mapname + " (" + Form . ActiveForm . Text + ") at " ;
2014-10-31 09:52:07 +00:00
bounds = ( Form . ActiveForm . WindowState = = FormWindowState . Maximized ?
Screen . GetWorkingArea ( Form . ActiveForm ) :
Form . ActiveForm . Bounds ) ;
2014-10-22 13:07:17 +00:00
}
else
{
name = mapname + " (edit area) at " ;
bounds = this . display . Bounds ;
bounds . Offset ( this . PointToScreen ( new Point ( ) ) ) ;
displayextrainfo = true ;
}
}
2014-10-31 09:52:07 +00:00
else
2014-10-22 13:07:17 +00:00
{
name = mapname + " at " ;
2014-10-31 09:52:07 +00:00
bounds = ( this . WindowState = = FormWindowState . Maximized ? Screen . GetWorkingArea ( this ) : this . Bounds ) ;
2013-06-05 08:08:56 +00:00
}
2014-01-17 14:41:38 +00:00
Point cursorLocation = Point . Empty ;
//dont want to render the cursor in VisualMode
if ( General . Editing . Mode = = null | | ! ( General . Editing . Mode is VisualMode ) )
cursorLocation = Cursor . Position - new Size ( bounds . Location ) ;
2013-06-05 08:08:56 +00:00
//create path
2014-10-31 09:52:07 +00:00
string date = DateTime . Now . ToString ( "yyyy.MM.dd HH-mm-ss.fff" ) ;
2014-12-10 21:11:56 +00:00
string revision = ( General . DebugBuild ? "DEVBUILD" : "R" + General . ThisAssembly . GetName ( ) . Version . MinorRevision ) ;
2014-09-16 15:22:32 +00:00
string path = Path . Combine ( folder , name + date + " [" + revision + "].jpg" ) ;
2013-06-05 08:08:56 +00:00
//save image
2014-10-22 13:07:17 +00:00
using ( Bitmap bitmap = new Bitmap ( bounds . Width , bounds . Height ) )
{
using ( Graphics g = Graphics . FromImage ( bitmap ) )
{
2013-06-05 08:08:56 +00:00
g . CopyFromScreen ( new Point ( bounds . Left , bounds . Top ) , Point . Empty , bounds . Size ) ;
2014-01-17 14:41:38 +00:00
//draw the cursor
if ( ! cursorLocation . IsEmpty ) g . DrawImage ( Resources . Cursor , cursorLocation ) ;
2014-02-10 10:16:47 +00:00
2014-08-06 14:24:23 +00:00
//gather some info
2014-10-22 13:07:17 +00:00
string info ;
if ( displayextrainfo & & General . Editing . Mode ! = null )
{
2014-09-16 15:22:32 +00:00
info = General . Map . FileTitle + " | " + General . Map . Options . CurrentName + " | " ;
2014-09-04 07:57:30 +00:00
2014-08-06 14:24:23 +00:00
//get map coordinates
2015-12-28 15:01:53 +00:00
if ( General . Editing . Mode is ClassicMode )
2014-10-22 13:07:17 +00:00
{
2014-08-06 14:24:23 +00:00
Vector2D pos = ( ( ClassicMode ) General . Editing . Mode ) . MouseMapPos ;
2014-02-10 10:16:47 +00:00
//mouse inside the view?
2015-12-28 15:01:53 +00:00
if ( pos . IsFinite ( ) )
2014-12-03 23:15:26 +00:00
{
2014-09-04 07:57:30 +00:00
info + = "X:" + Math . Round ( pos . x ) + " Y:" + Math . Round ( pos . y ) ;
2014-12-03 23:15:26 +00:00
}
else
{
2014-09-04 07:57:30 +00:00
info + = "X:" + Math . Round ( General . Map . Renderer2D . TranslateX ) + " Y:" + Math . Round ( General . Map . Renderer2D . TranslateY ) ;
2014-02-10 10:16:47 +00:00
}
2014-10-22 13:07:17 +00:00
}
else
{ //should be visual mode
2014-09-04 07:57:30 +00:00
info + = "X:" + Math . Round ( General . Map . VisualCamera . Position . x ) + " Y:" + Math . Round ( General . Map . VisualCamera . Position . y ) + " Z:" + Math . Round ( General . Map . VisualCamera . Position . z ) ;
2014-02-10 10:16:47 +00:00
}
2014-08-06 14:24:23 +00:00
//add the revision number
2014-09-16 15:22:32 +00:00
info + = " | " + revision ;
2014-10-22 13:07:17 +00:00
}
else
{
2014-08-06 14:24:23 +00:00
//just use the revision number
info = revision ;
2014-02-10 10:16:47 +00:00
}
2014-08-06 14:24:23 +00:00
//draw info
Font font = new Font ( "Tahoma" , 10 ) ;
SizeF rect = g . MeasureString ( info , font ) ;
float px = bounds . Width - rect . Width - 4 ;
float py = 4 ;
g . FillRectangle ( Brushes . Black , px , py , rect . Width , rect . Height + 3 ) ;
2015-05-27 10:34:25 +00:00
using ( SolidBrush brush = new SolidBrush ( Color . White ) )
{
g . DrawString ( info , font , brush , px + 2 , py + 2 ) ;
}
2013-06-06 15:58:48 +00:00
}
2013-06-05 08:08:56 +00:00
2014-10-22 13:07:17 +00:00
try
{
2013-06-10 14:04:23 +00:00
ImageCodecInfo jpegCodec = null ;
ImageCodecInfo [ ] codecs = ImageCodecInfo . GetImageDecoders ( ) ;
2014-10-22 13:07:17 +00:00
foreach ( ImageCodecInfo codec in codecs )
{
if ( codec . FormatID = = ImageFormat . Jpeg . Guid )
{
2013-06-10 14:04:23 +00:00
jpegCodec = codec ;
break ;
}
}
2013-06-06 15:58:48 +00:00
EncoderParameter qualityParam = new EncoderParameter ( Encoder . Quality , 90L ) ;
EncoderParameters encoderParams = new EncoderParameters ( 1 ) ;
encoderParams . Param [ 0 ] = qualityParam ;
bitmap . Save ( path , jpegCodec , encoderParams ) ;
2016-03-08 20:41:06 +00:00
DisplayStatus ( StatusType . Info , "Screenshot saved to \"" + path + "\"" ) ;
2014-10-22 13:07:17 +00:00
}
catch ( ExternalException e )
{
2013-06-06 15:58:48 +00:00
DisplayStatus ( StatusType . Warning , "Failed to save screenshot..." ) ;
General . ErrorLogger . Add ( ErrorType . Error , "Failed to save screenshot: " + e . Message ) ;
2013-06-06 10:22:58 +00:00
}
2013-06-05 08:08:56 +00:00
}
}
2009-04-19 18:07:22 +00:00
#endregion
2014-10-20 12:16:51 +00:00
#region = = = = = = = = = = = = = = = = = = Models and Lights mode ( mxd )
private void ChangeModelRenderingMode ( object sender , EventArgs e )
{
General . Settings . GZDrawModelsMode = ( ModelRenderMode ) ( ( ToolStripMenuItem ) sender ) . Tag ;
switch ( General . Settings . GZDrawModelsMode )
{
case ModelRenderMode . NONE :
General . MainWindow . DisplayStatus ( StatusType . Action , "Models rendering mode: NONE" ) ;
break ;
case ModelRenderMode . SELECTION :
General . MainWindow . DisplayStatus ( StatusType . Action , "Models rendering mode: SELECTION ONLY" ) ;
break ;
2015-06-27 09:10:24 +00:00
case ModelRenderMode . ACTIVE_THINGS_FILTER :
General . MainWindow . DisplayStatus ( StatusType . Action , "Models rendering mode: ACTIVE THINGS FILTER ONLY" ) ;
break ;
2014-10-20 12:16:51 +00:00
case ModelRenderMode . ALL :
General . MainWindow . DisplayStatus ( StatusType . Action , "Models rendering mode: ALL" ) ;
break ;
}
2016-09-07 15:15:07 +00:00
UpdateViewMenu ( ) ;
2014-10-20 12:16:51 +00:00
UpdateGZDoomPanel ( ) ;
RedrawDisplay ( ) ;
}
private void ChangeLightRenderingMode ( object sender , EventArgs e )
{
General . Settings . GZDrawLightsMode = ( LightRenderMode ) ( ( ToolStripMenuItem ) sender ) . Tag ;
switch ( General . Settings . GZDrawLightsMode )
{
case LightRenderMode . NONE :
General . MainWindow . DisplayStatus ( StatusType . Action , "Dynamic lights rendering mode: NONE" ) ;
break ;
case LightRenderMode . ALL :
General . MainWindow . DisplayStatus ( StatusType . Action , "Models rendering mode: ALL" ) ;
break ;
case LightRenderMode . ALL_ANIMATED :
General . MainWindow . DisplayStatus ( StatusType . Action , "Models rendering mode: ANIMATED" ) ;
break ;
}
2016-09-07 15:15:07 +00:00
UpdateViewMenu ( ) ;
2014-10-20 12:16:51 +00:00
UpdateGZDoomPanel ( ) ;
RedrawDisplay ( ) ;
}
#endregion
2009-04-19 18:07:22 +00:00
#region = = = = = = = = = = = = = = = = = = Info Panels
// This toggles the panel expanded / collapsed
[BeginAction("toggleinfopanel")]
internal void ToggleInfoPanel ( )
{
if ( IsInfoPanelExpanded )
{
2009-07-09 22:43:39 +00:00
panelinfo . Height = buttontoggleinfo . Height + buttontoggleinfo . Top ;
2015-01-09 08:11:42 +00:00
buttontoggleinfo . Image = Resources . InfoPanelExpand ; //mxd
2009-04-19 18:07:22 +00:00
if ( linedefinfo . Visible ) linedefinfo . Hide ( ) ;
if ( vertexinfo . Visible ) vertexinfo . Hide ( ) ;
if ( sectorinfo . Visible ) sectorinfo . Hide ( ) ;
if ( thinginfo . Visible ) thinginfo . Hide ( ) ;
2014-01-08 09:46:57 +00:00
modename . Visible = false ;
2014-11-13 09:43:39 +00:00
#if DEBUG
console . Visible = false ; //mxd
#endif
2014-05-08 12:34:24 +00:00
statistics . Visible = false ; //mxd
2009-04-19 18:07:22 +00:00
labelcollapsedinfo . Visible = true ;
itemtoggleinfo . Checked = false ;
}
else
{
2009-07-09 22:43:39 +00:00
panelinfo . Height = heightpanel1 . Height ;
2015-01-09 08:11:42 +00:00
buttontoggleinfo . Image = Resources . InfoPanelCollapse ; //mxd
2009-04-19 18:07:22 +00:00
labelcollapsedinfo . Visible = false ;
itemtoggleinfo . Checked = true ;
2016-03-18 12:52:12 +00:00
if ( lastinfoobject is Vertex ) ShowVertexInfo ( ( Vertex ) lastinfoobject ) ;
else if ( lastinfoobject is Linedef ) ShowLinedefInfo ( ( Linedef ) lastinfoobject ) ;
else if ( lastinfoobject is Sector ) ShowSectorInfo ( ( Sector ) lastinfoobject ) ;
else if ( lastinfoobject is Thing ) ShowThingInfo ( ( Thing ) lastinfoobject ) ;
2009-04-19 18:07:22 +00:00
else HideInfo ( ) ;
}
2014-02-26 14:11:06 +00:00
dockerspanel . Height = dockersspace . Height ; //mxd
2009-04-19 18:07:22 +00:00
FocusDisplay ( ) ;
}
// Mouse released on info panel toggle button
private void buttontoggleinfo_MouseUp ( object sender , MouseEventArgs e )
{
2014-02-26 14:11:06 +00:00
dockerspanel . Height = dockersspace . Height ; //mxd
2009-04-19 18:07:22 +00:00
FocusDisplay ( ) ;
}
// This displays the current mode name
internal void DisplayModeName ( string name )
{
2014-12-03 23:15:26 +00:00
if ( lastinfoobject = = null )
{
2014-01-08 09:46:57 +00:00
labelcollapsedinfo . Text = name ;
labelcollapsedinfo . Refresh ( ) ;
}
modename . Text = name ;
modename . Refresh ( ) ;
2009-04-19 18:07:22 +00:00
}
// This hides all info panels
public void HideInfo ( )
{
2019-01-14 18:07:08 +00:00
// Hide them all
// [ZZ]
panelinfo . SuspendLayout ( ) ;
2014-05-08 12:34:24 +00:00
bool showModeName = ( ( General . Map ! = null ) & & IsInfoPanelExpanded ) ; //mxd
2009-04-19 18:07:22 +00:00
lastinfoobject = null ;
if ( linedefinfo . Visible ) linedefinfo . Hide ( ) ;
if ( vertexinfo . Visible ) vertexinfo . Hide ( ) ;
if ( sectorinfo . Visible ) sectorinfo . Hide ( ) ;
if ( thinginfo . Visible ) thinginfo . Hide ( ) ;
2014-01-08 09:46:57 +00:00
labelcollapsedinfo . Text = modename . Text ;
2009-04-19 18:07:22 +00:00
labelcollapsedinfo . Refresh ( ) ;
2014-11-13 09:43:39 +00:00
#if DEBUG
console . Visible = true ;
#else
2014-05-08 12:34:24 +00:00
modename . Visible = showModeName ;
2014-11-13 09:43:39 +00:00
#endif
2014-01-08 09:46:57 +00:00
modename . Refresh ( ) ;
2014-05-08 12:34:24 +00:00
statistics . Visible = showModeName ; //mxd
2012-10-09 15:17:52 +00:00
2016-03-18 12:52:12 +00:00
//mxd. Let the plugins know
2013-09-11 09:47:53 +00:00
General . Plugins . OnHighlightLost ( ) ;
2019-01-14 18:07:08 +00:00
// [ZZ]
panelinfo . ResumeLayout ( ) ;
2009-04-19 18:07:22 +00:00
}
// This refreshes info
public void RefreshInfo ( )
{
2016-03-18 12:52:12 +00:00
if ( lastinfoobject is Vertex ) ShowVertexInfo ( ( Vertex ) lastinfoobject ) ;
else if ( lastinfoobject is Linedef ) ShowLinedefInfo ( ( Linedef ) lastinfoobject ) ;
else if ( lastinfoobject is Sector ) ShowSectorInfo ( ( Sector ) lastinfoobject ) ;
else if ( lastinfoobject is Thing ) ShowThingInfo ( ( Thing ) lastinfoobject ) ;
2012-10-09 15:17:52 +00:00
2019-01-14 18:07:08 +00:00
//mxd. Let the plugins know
// [ZZ]
panelinfo . SuspendLayout ( ) ;
2013-09-11 09:47:53 +00:00
General . Plugins . OnHighlightRefreshed ( lastinfoobject ) ;
2019-01-14 18:07:08 +00:00
panelinfo . ResumeLayout ( ) ;
2009-04-19 18:07:22 +00:00
}
2013-12-10 12:19:27 +00:00
//mxd
2014-10-22 13:07:17 +00:00
public void ShowHints ( string hintsText )
{
2015-12-28 15:01:53 +00:00
if ( ! string . IsNullOrEmpty ( hintsText ) )
2014-10-22 13:07:17 +00:00
{
2014-01-08 09:46:57 +00:00
hintsPanel . SetHints ( hintsText ) ;
2014-10-22 13:07:17 +00:00
}
else
{
2014-01-23 13:36:51 +00:00
ClearHints ( ) ;
2013-12-11 08:47:11 +00:00
}
2013-12-10 12:19:27 +00:00
}
//mxd
2014-10-22 13:07:17 +00:00
public void ClearHints ( )
{
2014-01-08 09:46:57 +00:00
hintsPanel . ClearHints ( ) ;
}
//mxd
2014-10-22 13:07:17 +00:00
internal void AddHintsDocker ( )
{
2016-04-15 14:24:18 +00:00
if ( ! dockerspanel . Contains ( hintsDocker ) ) dockerspanel . Add ( hintsDocker , false ) ;
2014-01-08 09:46:57 +00:00
}
//mxd
2014-10-22 13:07:17 +00:00
internal void RemoveHintsDocker ( )
{
2014-01-08 09:46:57 +00:00
dockerspanel . Remove ( hintsDocker ) ;
2013-12-10 12:19:27 +00:00
}
2015-02-25 19:59:17 +00:00
//mxd. Show linedef info
public void ShowLinedefInfo ( Linedef l )
{
ShowLinedefInfo ( l , null ) ;
}
2009-04-19 18:07:22 +00:00
2015-02-25 19:59:17 +00:00
//mxd. Show linedef info and highlight given sidedef
public void ShowLinedefInfo ( Linedef l , Sidedef highlightside )
2009-04-19 18:07:22 +00:00
{
2010-08-01 18:49:46 +00:00
if ( l . IsDisposed )
{
HideInfo ( ) ;
return ;
}
2017-02-09 17:14:05 +00:00
2019-01-14 18:07:08 +00:00
// [ZZ]
panelinfo . SuspendLayout ( ) ;
lastinfoobject = l ;
2014-01-08 09:46:57 +00:00
modename . Visible = false ;
2014-11-13 09:43:39 +00:00
#if DEBUG
console . Visible = console . AlwaysOnTop ; //mxd
#endif
2014-05-08 12:34:24 +00:00
statistics . Visible = false ; //mxd
2009-04-19 18:07:22 +00:00
if ( vertexinfo . Visible ) vertexinfo . Hide ( ) ;
if ( sectorinfo . Visible ) sectorinfo . Hide ( ) ;
if ( thinginfo . Visible ) thinginfo . Hide ( ) ;
2015-02-25 19:59:17 +00:00
if ( IsInfoPanelExpanded ) linedefinfo . ShowInfo ( l , highlightside ) ;
2014-01-08 09:46:57 +00:00
// Show info on collapsed label
2014-12-03 23:15:26 +00:00
if ( General . Map . Config . LinedefActions . ContainsKey ( l . Action ) )
{
2014-01-08 09:46:57 +00:00
LinedefActionInfo act = General . Map . Config . LinedefActions [ l . Action ] ;
labelcollapsedinfo . Text = act . ToString ( ) ;
2014-12-03 23:15:26 +00:00
}
2015-12-28 15:01:53 +00:00
else if ( l . Action = = 0 )
2014-12-03 23:15:26 +00:00
{
2014-02-21 14:42:12 +00:00
labelcollapsedinfo . Text = l . Action + " - None" ;
2014-12-03 23:15:26 +00:00
}
2014-01-08 09:46:57 +00:00
else
2014-12-03 23:15:26 +00:00
{
2014-02-21 14:42:12 +00:00
labelcollapsedinfo . Text = l . Action + " - Unknown" ;
2014-12-03 23:15:26 +00:00
}
2014-01-08 09:46:57 +00:00
labelcollapsedinfo . Refresh ( ) ;
2012-10-09 15:17:52 +00:00
2019-01-14 18:07:08 +00:00
//mxd. let the plugins know
General . Plugins . OnHighlightLinedef ( l ) ;
// [ZZ]
panelinfo . ResumeLayout ( ) ;
}
2009-04-19 18:07:22 +00:00
// Show vertex info
2014-12-03 23:15:26 +00:00
public void ShowVertexInfo ( Vertex v )
{
2015-12-28 15:01:53 +00:00
if ( v . IsDisposed )
2014-12-03 23:15:26 +00:00
{
2010-08-01 18:49:46 +00:00
HideInfo ( ) ;
return ;
}
2019-01-14 18:07:08 +00:00
// [ZZ]
panelinfo . SuspendLayout ( ) ;
lastinfoobject = v ;
2014-01-08 09:46:57 +00:00
modename . Visible = false ;
2014-11-13 09:43:39 +00:00
#if DEBUG
console . Visible = console . AlwaysOnTop ; //mxd
#endif
2014-05-08 12:34:24 +00:00
statistics . Visible = false ; //mxd
2015-12-28 15:01:53 +00:00
if ( linedefinfo . Visible ) linedefinfo . Hide ( ) ;
if ( sectorinfo . Visible ) sectorinfo . Hide ( ) ;
if ( thinginfo . Visible ) thinginfo . Hide ( ) ;
if ( IsInfoPanelExpanded ) vertexinfo . ShowInfo ( v ) ;
2014-01-08 09:46:57 +00:00
// Show info on collapsed label
labelcollapsedinfo . Text = v . Position . x . ToString ( "0.##" ) + ", " + v . Position . y . ToString ( "0.##" ) ;
labelcollapsedinfo . Refresh ( ) ;
2012-10-09 15:17:52 +00:00
2013-09-11 09:47:53 +00:00
//mxd. let the plugins know
General . Plugins . OnHighlightVertex ( v ) ;
2019-01-14 18:07:08 +00:00
// [ZZ]
panelinfo . ResumeLayout ( ) ;
}
2009-04-19 18:07:22 +00:00
2019-01-14 18:07:08 +00:00
//mxd. Show sector info
public void ShowSectorInfo ( Sector s )
Fixed(?), Texture Browser: possibly fixed Texture Browser not showing up / locking edit forms when current map has a ton of textures (like 2000 or more) in a single texture group.
Changed, cosmetic, Sector Info panel, Visual mode: info about currently highlighted surface is now shown using different color.
Changed, cosmetic, Linedef Info panel, Visual mode, non-UDMF: texture offset labels for currently highlighted sidedef are now shown using different color.
Changed, cosmetic, Vertex Info panel, UDMF: floor and ceiling offset labels are now grayed out when they have default values.
2015-03-23 22:39:31 +00:00
{
ShowSectorInfo ( s , false , false ) ;
}
// Show sector info
public void ShowSectorInfo ( Sector s , bool highlightceiling , bool highlightfloor )
2014-12-03 23:15:26 +00:00
{
2015-12-28 15:01:53 +00:00
if ( s . IsDisposed )
2014-12-03 23:15:26 +00:00
{
2010-08-01 18:49:46 +00:00
HideInfo ( ) ;
return ;
}
2019-01-14 18:07:08 +00:00
// [ZZ]
panelinfo . SuspendLayout ( ) ;
lastinfoobject = s ;
2014-01-08 09:46:57 +00:00
modename . Visible = false ;
2014-11-13 09:43:39 +00:00
#if DEBUG
console . Visible = console . AlwaysOnTop ; //mxd
#endif
2014-05-08 12:34:24 +00:00
statistics . Visible = false ; //mxd
2015-12-28 15:01:53 +00:00
if ( linedefinfo . Visible ) linedefinfo . Hide ( ) ;
if ( vertexinfo . Visible ) vertexinfo . Hide ( ) ;
if ( thinginfo . Visible ) thinginfo . Hide ( ) ;
Fixed(?), Texture Browser: possibly fixed Texture Browser not showing up / locking edit forms when current map has a ton of textures (like 2000 or more) in a single texture group.
Changed, cosmetic, Sector Info panel, Visual mode: info about currently highlighted surface is now shown using different color.
Changed, cosmetic, Linedef Info panel, Visual mode, non-UDMF: texture offset labels for currently highlighted sidedef are now shown using different color.
Changed, cosmetic, Vertex Info panel, UDMF: floor and ceiling offset labels are now grayed out when they have default values.
2015-03-23 22:39:31 +00:00
if ( IsInfoPanelExpanded ) sectorinfo . ShowInfo ( s , highlightceiling , highlightfloor ) ; //mxd
2009-04-19 18:07:22 +00:00
2014-01-08 09:46:57 +00:00
// Show info on collapsed label
if ( General . Map . Config . SectorEffects . ContainsKey ( s . Effect ) )
labelcollapsedinfo . Text = General . Map . Config . SectorEffects [ s . Effect ] . ToString ( ) ;
else if ( s . Effect = = 0 )
2014-02-21 14:42:12 +00:00
labelcollapsedinfo . Text = s . Effect + " - Normal" ;
2014-01-08 09:46:57 +00:00
else
2014-02-21 14:42:12 +00:00
labelcollapsedinfo . Text = s . Effect + " - Unknown" ;
2014-01-08 09:46:57 +00:00
labelcollapsedinfo . Refresh ( ) ;
2012-10-09 15:17:52 +00:00
2019-01-14 18:07:08 +00:00
//mxd. let the plugins know
General . Plugins . OnHighlightSector ( s ) ;
// [ZZ]
panelinfo . ResumeLayout ( ) ;
}
2009-04-19 18:07:22 +00:00
2019-01-14 18:07:08 +00:00
// Show thing info
public void ShowThingInfo ( Thing t )
2009-04-19 18:07:22 +00:00
{
2010-08-01 18:49:46 +00:00
if ( t . IsDisposed )
{
HideInfo ( ) ;
return ;
}
2019-01-14 18:07:08 +00:00
// [ZZ]
panelinfo . SuspendLayout ( ) ;
lastinfoobject = t ;
2014-01-08 09:46:57 +00:00
modename . Visible = false ;
2014-11-13 09:43:39 +00:00
#if DEBUG
console . Visible = console . AlwaysOnTop ; //mxd
#endif
2014-05-08 12:34:24 +00:00
statistics . Visible = false ; //mxd
2009-04-19 18:07:22 +00:00
if ( linedefinfo . Visible ) linedefinfo . Hide ( ) ;
if ( vertexinfo . Visible ) vertexinfo . Hide ( ) ;
if ( sectorinfo . Visible ) sectorinfo . Hide ( ) ;
2014-01-08 09:46:57 +00:00
if ( IsInfoPanelExpanded ) thinginfo . ShowInfo ( t ) ;
// Show info on collapsed label
ThingTypeInfo ti = General . Map . Data . GetThingInfo ( t . Type ) ;
labelcollapsedinfo . Text = t . Type + " - " + ti . Title ;
labelcollapsedinfo . Refresh ( ) ;
2012-10-09 15:17:52 +00:00
2019-01-14 18:07:08 +00:00
//mxd. let the plugins know
General . Plugins . OnHighlightThing ( t ) ;
// [ZZ]
panelinfo . ResumeLayout ( ) ;
}
2009-04-19 18:07:22 +00:00
2019-01-14 18:07:08 +00:00
#endregion
2009-04-19 18:07:22 +00:00
2019-01-14 18:07:08 +00:00
#region = = = = = = = = = = = = = = = = = = Dialogs
2009-04-19 18:07:22 +00:00
2019-01-14 18:07:08 +00:00
// This browses for a texture
// Returns the new texture name or the same texture name when cancelled
public string BrowseTexture ( IWin32Window owner , string initialvalue )
2009-04-19 18:07:22 +00:00
{
2012-07-23 21:28:23 +00:00
return TextureBrowserForm . Browse ( owner , initialvalue , false ) ; //mxd
2009-04-19 18:07:22 +00:00
}
// This browses for a flat
// Returns the new flat name or the same flat name when cancelled
public string BrowseFlat ( IWin32Window owner , string initialvalue )
{
2013-09-11 09:47:53 +00:00
return TextureBrowserForm . Browse ( owner , initialvalue , true ) ; //mxd. was FlatBrowserForm
2009-04-19 18:07:22 +00:00
}
// This browses the lindef types
// Returns the new action or the same action when cancelled
public int BrowseLinedefActions ( IWin32Window owner , int initialvalue )
{
2016-02-21 00:11:09 +00:00
return ActionBrowserForm . BrowseAction ( owner , initialvalue , false ) ;
}
//mxd. This browses the lindef types
// Returns the new action or the same action when cancelled
public int BrowseLinedefActions ( IWin32Window owner , int initialvalue , bool addanyaction )
{
return ActionBrowserForm . BrowseAction ( owner , initialvalue , addanyaction ) ;
2009-04-19 18:07:22 +00:00
}
// This browses sector effects
// Returns the new effect or the same effect when cancelled
public int BrowseSectorEffect ( IWin32Window owner , int initialvalue )
{
2016-02-21 00:11:09 +00:00
return EffectBrowserForm . BrowseEffect ( owner , initialvalue , false ) ;
}
//mxd. This browses sector effects
// Returns the new effect or the same effect when cancelled
public int BrowseSectorEffect ( IWin32Window owner , int initialvalue , bool addanyeffect )
{
return EffectBrowserForm . BrowseEffect ( owner , initialvalue , addanyeffect ) ;
2009-04-19 18:07:22 +00:00
}
// This browses thing types
// Returns the new thing type or the same thing type when cancelled
public int BrowseThingType ( IWin32Window owner , int initialvalue )
{
return ThingBrowserForm . BrowseThing ( owner , initialvalue ) ;
}
2013-03-18 13:52:27 +00:00
//mxd
2014-09-15 14:12:31 +00:00
public DialogResult ShowEditVertices ( ICollection < Vertex > vertices )
{
2013-03-18 13:52:27 +00:00
return ShowEditVertices ( vertices , true ) ;
}
//mxd. This shows the dialog to edit vertices
public DialogResult ShowEditVertices ( ICollection < Vertex > vertices , bool allowPositionChange )
2009-04-19 18:07:22 +00:00
{
// Show sector edit dialog
VertexEditForm f = new VertexEditForm ( ) ;
Fixed(?), Texture Browser: possibly fixed Texture Browser not showing up / locking edit forms when current map has a ton of textures (like 2000 or more) in a single texture group.
Changed, cosmetic, Sector Info panel, Visual mode: info about currently highlighted surface is now shown using different color.
Changed, cosmetic, Linedef Info panel, Visual mode, non-UDMF: texture offset labels for currently highlighted sidedef are now shown using different color.
Changed, cosmetic, Vertex Info panel, UDMF: floor and ceiling offset labels are now grayed out when they have default values.
2015-03-23 22:39:31 +00:00
DisableProcessing ( ) ; //mxd
2020-09-13 16:40:09 +00:00
#if NO_WIN32
BreakExclusiveMouseInput ( ) ;
f . Closed + = ( object sender , EventArgs e ) = > {
ResumeExclusiveMouseInput ( ) ;
EnableProcessing ( ) ; //mxd
} ;
#endif
2013-03-18 13:52:27 +00:00
f . Setup ( vertices , allowPositionChange ) ;
2020-09-13 16:40:09 +00:00
#if ! NO_WIN32
Fixed(?), Texture Browser: possibly fixed Texture Browser not showing up / locking edit forms when current map has a ton of textures (like 2000 or more) in a single texture group.
Changed, cosmetic, Sector Info panel, Visual mode: info about currently highlighted surface is now shown using different color.
Changed, cosmetic, Linedef Info panel, Visual mode, non-UDMF: texture offset labels for currently highlighted sidedef are now shown using different color.
Changed, cosmetic, Vertex Info panel, UDMF: floor and ceiling offset labels are now grayed out when they have default values.
2015-03-23 22:39:31 +00:00
EnableProcessing ( ) ; //mxd
2020-09-13 16:40:09 +00:00
#endif
2014-02-21 14:42:12 +00:00
f . OnValuesChanged + = EditForm_OnValuesChanged ;
2014-01-11 10:23:42 +00:00
editformopen = true ; //mxd
DialogResult result = f . ShowDialog ( this ) ;
editformopen = false ; //mxd
2009-04-19 18:07:22 +00:00
f . Dispose ( ) ;
return result ;
}
// This shows the dialog to edit lines
public DialogResult ShowEditLinedefs ( ICollection < Linedef > lines )
2015-06-15 09:50:22 +00:00
{
return ShowEditLinedefs ( lines , false , false ) ;
}
// This shows the dialog to edit lines
public DialogResult ShowEditLinedefs ( ICollection < Linedef > lines , bool selectfront , bool selectback )
2009-04-19 18:07:22 +00:00
{
2014-09-15 14:12:31 +00:00
DialogResult result ;
2009-04-19 18:07:22 +00:00
// Show line edit dialog
2014-09-15 14:12:31 +00:00
if ( General . Map . UDMF ) //mxd
{
2017-02-07 18:02:31 +00:00
LinedefEditFormUDMF f = new LinedefEditFormUDMF ( selectfront , selectback ) ;
DisableProcessing ( ) ; //mxd
2020-09-13 16:40:09 +00:00
#if NO_WIN32
BreakExclusiveMouseInput ( ) ;
f . Closed + = ( object sender , EventArgs e ) = > {
ResumeExclusiveMouseInput ( ) ;
EnableProcessing ( ) ; //mxd
} ;
#endif
2017-02-08 12:20:03 +00:00
f . Setup ( lines , selectfront , selectback ) ;
2020-09-13 16:40:09 +00:00
#if ! NO_WIN32
EnableProcessing ( ) ;
#endif
2014-09-15 14:12:31 +00:00
f . OnValuesChanged + = EditForm_OnValuesChanged ;
editformopen = true ; //mxd
result = f . ShowDialog ( this ) ;
editformopen = false ; //mxd
2017-02-07 18:02:31 +00:00
f . Dispose ( ) ;
2014-09-15 14:12:31 +00:00
}
else
{
2017-02-07 18:02:31 +00:00
LinedefEditForm f = new LinedefEditForm ( ) ;
DisableProcessing ( ) ; //mxd
2020-09-13 16:40:09 +00:00
#if NO_WIN32
BreakExclusiveMouseInput ( ) ;
f . Closed + = ( object sender , EventArgs e ) = > {
ResumeExclusiveMouseInput ( ) ;
EnableProcessing ( ) ; //mxd
} ;
#endif
2014-09-15 14:12:31 +00:00
f . Setup ( lines ) ;
2020-09-13 16:40:09 +00:00
#if ! NO_WIN32
EnableProcessing ( ) ;
#endif
2014-09-15 14:12:31 +00:00
f . OnValuesChanged + = EditForm_OnValuesChanged ;
editformopen = true ; //mxd
result = f . ShowDialog ( this ) ;
editformopen = false ; //mxd
2017-02-07 18:02:31 +00:00
f . Dispose ( ) ;
2014-09-15 14:12:31 +00:00
}
2009-04-19 18:07:22 +00:00
return result ;
}
// This shows the dialog to edit sectors
public DialogResult ShowEditSectors ( ICollection < Sector > sectors )
{
DialogResult result ;
// Show sector edit dialog
2014-09-15 14:12:31 +00:00
if ( General . Map . UDMF ) //mxd
{
2017-02-07 18:02:31 +00:00
SectorEditFormUDMF f = new SectorEditFormUDMF ( ) ;
DisableProcessing ( ) ; //mxd
2020-09-13 16:40:09 +00:00
#if NO_WIN32
BreakExclusiveMouseInput ( ) ;
f . Closed + = ( object sender , EventArgs e ) = > {
ResumeExclusiveMouseInput ( ) ;
EnableProcessing ( ) ; //mxd
} ;
#endif
2013-06-25 12:35:13 +00:00
f . Setup ( sectors ) ;
2020-09-13 16:40:09 +00:00
#if ! NO_WIN32
Fixed(?), Texture Browser: possibly fixed Texture Browser not showing up / locking edit forms when current map has a ton of textures (like 2000 or more) in a single texture group.
Changed, cosmetic, Sector Info panel, Visual mode: info about currently highlighted surface is now shown using different color.
Changed, cosmetic, Linedef Info panel, Visual mode, non-UDMF: texture offset labels for currently highlighted sidedef are now shown using different color.
Changed, cosmetic, Vertex Info panel, UDMF: floor and ceiling offset labels are now grayed out when they have default values.
2015-03-23 22:39:31 +00:00
EnableProcessing ( ) ; //mxd
2020-09-13 16:40:09 +00:00
#endif
2014-02-21 14:42:12 +00:00
f . OnValuesChanged + = EditForm_OnValuesChanged ;
2014-01-11 10:23:42 +00:00
editformopen = true ; //mxd
2013-06-25 12:35:13 +00:00
result = f . ShowDialog ( this ) ;
2014-01-11 10:23:42 +00:00
editformopen = false ; //mxd
2017-02-07 18:02:31 +00:00
f . Dispose ( ) ;
2014-09-15 14:12:31 +00:00
}
else
{
2017-02-07 18:02:31 +00:00
SectorEditForm f = new SectorEditForm ( ) ;
DisableProcessing ( ) ; //mxd
2020-09-13 16:40:09 +00:00
#if NO_WIN32
BreakExclusiveMouseInput ( ) ;
f . Closed + = ( object sender , EventArgs e ) = > {
ResumeExclusiveMouseInput ( ) ;
EnableProcessing ( ) ; //mxd
} ;
#endif
2013-06-25 12:35:13 +00:00
f . Setup ( sectors ) ;
2020-09-13 16:40:09 +00:00
#if ! NO_WIN32
Fixed(?), Texture Browser: possibly fixed Texture Browser not showing up / locking edit forms when current map has a ton of textures (like 2000 or more) in a single texture group.
Changed, cosmetic, Sector Info panel, Visual mode: info about currently highlighted surface is now shown using different color.
Changed, cosmetic, Linedef Info panel, Visual mode, non-UDMF: texture offset labels for currently highlighted sidedef are now shown using different color.
Changed, cosmetic, Vertex Info panel, UDMF: floor and ceiling offset labels are now grayed out when they have default values.
2015-03-23 22:39:31 +00:00
EnableProcessing ( ) ; //mxd
2020-09-13 16:40:09 +00:00
#endif
2014-02-21 14:42:12 +00:00
f . OnValuesChanged + = EditForm_OnValuesChanged ;
2014-01-11 10:23:42 +00:00
editformopen = true ; //mxd
2013-06-25 12:35:13 +00:00
result = f . ShowDialog ( this ) ;
2014-01-11 10:23:42 +00:00
editformopen = false ; //mxd
2017-02-07 18:02:31 +00:00
f . Dispose ( ) ;
2013-06-25 12:35:13 +00:00
}
2009-04-19 18:07:22 +00:00
return result ;
}
// This shows the dialog to edit things
2014-04-21 09:30:00 +00:00
public DialogResult ShowEditThings ( ICollection < Thing > things )
2009-04-19 18:07:22 +00:00
{
2014-04-21 09:30:00 +00:00
DialogResult result ;
2009-04-19 18:07:22 +00:00
// Show thing edit dialog
2014-09-15 14:12:31 +00:00
if ( General . Map . UDMF )
{
2017-02-07 18:02:31 +00:00
ThingEditFormUDMF f = new ThingEditFormUDMF ( ) ;
DisableProcessing ( ) ; //mxd
2020-09-13 16:40:09 +00:00
#if NO_WIN32
BreakExclusiveMouseInput ( ) ;
f . Closed + = ( object sender , EventArgs e ) = > {
ResumeExclusiveMouseInput ( ) ;
EnableProcessing ( ) ; //mxd
} ;
#endif
2014-04-21 09:30:00 +00:00
f . Setup ( things ) ;
2020-09-13 16:40:09 +00:00
#if ! NO_WIN32
Fixed(?), Texture Browser: possibly fixed Texture Browser not showing up / locking edit forms when current map has a ton of textures (like 2000 or more) in a single texture group.
Changed, cosmetic, Sector Info panel, Visual mode: info about currently highlighted surface is now shown using different color.
Changed, cosmetic, Linedef Info panel, Visual mode, non-UDMF: texture offset labels for currently highlighted sidedef are now shown using different color.
Changed, cosmetic, Vertex Info panel, UDMF: floor and ceiling offset labels are now grayed out when they have default values.
2015-03-23 22:39:31 +00:00
EnableProcessing ( ) ; //mxd
2020-09-13 16:40:09 +00:00
#endif
2014-04-21 09:30:00 +00:00
f . OnValuesChanged + = EditForm_OnValuesChanged ;
editformopen = true ; //mxd
result = f . ShowDialog ( this ) ;
editformopen = false ; //mxd
2017-02-07 18:02:31 +00:00
f . Dispose ( ) ;
2014-09-15 14:12:31 +00:00
}
else
{
2017-02-07 18:02:31 +00:00
ThingEditForm f = new ThingEditForm ( ) ;
DisableProcessing ( ) ; //mxd
2020-09-13 16:40:09 +00:00
#if NO_WIN32
BreakExclusiveMouseInput ( ) ;
f . Closed + = ( object sender , EventArgs e ) = > {
ResumeExclusiveMouseInput ( ) ;
EnableProcessing ( ) ; //mxd
} ;
#endif
2014-04-21 09:30:00 +00:00
f . Setup ( things ) ;
2020-09-13 16:40:09 +00:00
#if ! NO_WIN32
Fixed(?), Texture Browser: possibly fixed Texture Browser not showing up / locking edit forms when current map has a ton of textures (like 2000 or more) in a single texture group.
Changed, cosmetic, Sector Info panel, Visual mode: info about currently highlighted surface is now shown using different color.
Changed, cosmetic, Linedef Info panel, Visual mode, non-UDMF: texture offset labels for currently highlighted sidedef are now shown using different color.
Changed, cosmetic, Vertex Info panel, UDMF: floor and ceiling offset labels are now grayed out when they have default values.
2015-03-23 22:39:31 +00:00
EnableProcessing ( ) ; //mxd
2020-09-13 16:40:09 +00:00
#endif
2014-04-21 09:30:00 +00:00
f . OnValuesChanged + = EditForm_OnValuesChanged ;
editformopen = true ; //mxd
result = f . ShowDialog ( this ) ;
editformopen = false ; //mxd
2017-02-07 18:02:31 +00:00
f . Dispose ( ) ;
2014-04-21 09:30:00 +00:00
}
2009-04-19 18:07:22 +00:00
return result ;
}
2013-07-08 13:13:28 +00:00
//mxd
2014-09-15 14:12:31 +00:00
private void EditForm_OnValuesChanged ( object sender , EventArgs e )
{
2015-12-28 15:01:53 +00:00
if ( OnEditFormValuesChanged ! = null )
2014-09-15 14:12:31 +00:00
{
2014-09-03 14:07:08 +00:00
OnEditFormValuesChanged ( sender , e ) ;
2014-09-15 14:12:31 +00:00
}
else
{
2014-09-03 14:07:08 +00:00
//If current mode doesn't handle this event, let's at least update the map and redraw display.
General . Map . Map . Update ( ) ;
RedrawDisplay ( ) ;
}
2013-07-08 13:13:28 +00:00
}
2019-12-27 03:37:10 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Threadsafe updates
2019-12-29 19:48:11 +00:00
object syncobject = new object ( ) ;
List < System . Action > queuedActions = new List < System . Action > ( ) ;
2020-09-11 21:17:30 +00:00
internal void ProcessQueuedUIActions ( )
2019-12-29 19:48:11 +00:00
{
List < System . Action > queue ;
lock ( syncobject )
{
queue = queuedActions ;
queuedActions = new List < System . Action > ( ) ;
}
foreach ( System . Action action in queue )
{
action ( ) ;
}
}
2019-12-28 20:01:57 +00:00
public void RunOnUIThread ( System . Action action )
2019-12-27 03:37:10 +00:00
{
2019-12-28 20:01:57 +00:00
if ( ! InvokeRequired )
2019-12-28 19:37:05 +00:00
{
2019-12-28 20:01:57 +00:00
action ( ) ;
}
2019-12-29 02:54:12 +00:00
else
2019-12-28 20:01:57 +00:00
{
2019-12-29 19:48:11 +00:00
bool notify ;
lock ( syncobject )
{
notify = queuedActions . Count = = 0 ;
queuedActions . Add ( action ) ;
}
if ( notify )
2020-09-11 21:17:30 +00:00
General . InvokeUIActions ( this ) ;
2019-12-29 02:54:12 +00:00
}
2019-12-27 03:37:10 +00:00
}
public void UpdateStatus ( )
{
RunOnUIThread ( ( ) = >
{
DisplayStatus ( status ) ;
} ) ;
}
public void ImageDataLoaded ( string imagename )
{
RunOnUIThread ( ( ) = >
{
if ( ( General . Map ! = null ) & & ( General . Map . Data ! = null ) )
{
ImageData img = General . Map . Data . GetFlatImage ( imagename ) ;
ImageDataLoaded ( img ) ;
}
} ) ;
}
public void SpriteDataLoaded ( string spritename )
{
RunOnUIThread ( ( ) = >
{
if ( ( General . Map ! = null ) & & ( General . Map . Data ! = null ) )
{
ImageData img = General . Map . Data . GetSpriteImage ( spritename ) ;
if ( img ! = null & & img . UsedInMap & & ! img . IsDisposed )
{
DelayedRedraw ( ) ;
}
}
} ) ;
}
#endregion
#region = = = = = = = = = = = = = = = = = = Message Pump
// This handles messages
protected override void WndProc ( ref Message m )
2009-04-19 18:07:22 +00:00
{
// Notify message?
switch ( m . Msg )
{
2019-12-29 19:48:11 +00:00
case General . WM_UIACTION :
ProcessQueuedUIActions ( ) ;
break ;
case General . WM_SYSCOMMAND :
2009-04-19 18:07:22 +00:00
// We don't want to open a menu when ALT is pressed
if ( m . WParam . ToInt32 ( ) ! = General . SC_KEYMENU )
{
base . WndProc ( ref m ) ;
}
break ;
2017-03-25 01:47:18 +00:00
2019-01-14 18:07:08 +00:00
case General . WM_MOUSEHWHEEL :
2020-07-07 10:56:42 +00:00
int delta = unchecked ( ( short ) ( m . WParam . ToInt64 ( ) > > 16 ) ) ;
OnMouseHWheel ( delta ) ;
2019-01-14 18:07:08 +00:00
m . Result = new IntPtr ( delta ) ;
break ;
2009-04-19 18:07:22 +00:00
default :
// Let the base handle the message
base . WndProc ( ref m ) ;
break ;
}
}
2012-06-01 10:17:47 +00:00
2013-09-11 09:47:53 +00:00
//mxd. Warnings panel
2015-08-31 22:06:44 +00:00
private delegate void SetWarningsCountCallback ( int count , bool blink ) ;
2014-12-03 23:15:26 +00:00
internal void SetWarningsCount ( int count , bool blink )
{
2019-12-28 19:37:05 +00:00
RunOnUIThread ( ( ) = >
{
// Update icon, start annoying blinking if necessary
if ( count > 0 )
{
if ( blink & & ! blinkTimer . Enabled ) blinkTimer . Start ( ) ;
warnsLabel . Image = Resources . Warning ;
}
else
{
blinkTimer . Stop ( ) ;
warnsLabel . Image = Resources . WarningOff ;
warnsLabel . BackColor = SystemColors . Control ;
}
2015-08-31 22:06:44 +00:00
2019-12-28 19:37:05 +00:00
// Update errors count
warnsLabel . Text = count . ToString ( ) ;
} ) ;
2013-09-11 09:47:53 +00:00
}
2012-06-01 10:17:47 +00:00
2013-03-18 13:52:27 +00:00
//mxd. Bliks warnings indicator
2014-12-03 23:15:26 +00:00
private void Blink ( )
{
2013-11-29 12:24:47 +00:00
warnsLabel . BackColor = ( warnsLabel . BackColor = = Color . Red ? SystemColors . Control : Color . Red ) ;
2013-03-18 13:52:27 +00:00
}
2013-09-11 09:47:53 +00:00
//mxd
2014-12-03 23:15:26 +00:00
private void warnsLabel_Click ( object sender , EventArgs e )
{
2013-09-11 09:47:53 +00:00
ShowErrors ( ) ;
}
2012-06-01 10:17:47 +00:00
2013-03-18 13:52:27 +00:00
//mxd
2014-12-03 23:15:26 +00:00
private void blinkTimer_Elapsed ( object sender , System . Timers . ElapsedEventArgs e )
{
2016-02-01 22:04:00 +00:00
if ( ! blinkTimer . Enabled ) return ;
2014-12-03 23:15:26 +00:00
try
{
2019-12-28 19:37:05 +00:00
RunOnUIThread ( ( ) = >
{
Blink ( ) ;
} ) ;
2013-11-29 12:24:47 +00:00
} catch ( ObjectDisposedException ) { } //la-la-la. We don't care.
2013-03-18 13:52:27 +00:00
}
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Processing
// This is called from the background thread when images are loaded
// but only when first loaded or when dimensions were changed
internal void ImageDataLoaded ( ImageData img )
{
2019-01-14 18:07:08 +00:00
// Image is used in the map?
if ( ( img ! = null ) & & img . UsedInMap & & ! img . IsDisposed )
2009-04-19 18:07:22 +00:00
{
2019-01-14 18:07:08 +00:00
// Go for all setors
bool updated = false ;
2016-03-23 14:52:33 +00:00
long imgshorthash = General . Map . Data . GetShortLongFlatName ( img . LongName ) ; //mxd. Part of long name support shennanigans
2009-04-19 18:07:22 +00:00
foreach ( Sector s in General . Map . Map . Sectors )
{
// Update floor buffer if needed
2016-03-23 14:52:33 +00:00
if ( s . LongFloorTexture = = img . LongName | | s . LongFloorTexture = = imgshorthash )
2009-04-19 18:07:22 +00:00
{
s . UpdateFloorSurface ( ) ;
updated = true ;
}
// Update ceiling buffer if needed
2016-03-23 14:52:33 +00:00
if ( s . LongCeilTexture = = img . LongName | | s . LongCeilTexture = = imgshorthash )
2009-04-19 18:07:22 +00:00
{
2019-01-14 18:07:08 +00:00
s . UpdateCeilingSurface ( ) ;
2009-04-19 18:07:22 +00:00
updated = true ;
}
}
// If we made updates, redraw the screen
if ( updated ) DelayedRedraw ( ) ;
}
2019-01-14 18:07:08 +00:00
}
2009-04-19 18:07:22 +00:00
public void EnableProcessing ( )
{
// Increase count
processingcount + + ;
// If not already enabled, enable processing now
if ( ! processor . Enabled )
{
processor . Enabled = true ;
2014-05-20 09:09:28 +00:00
lastupdatetime = Clock . CurrentTime ;
2009-04-19 18:07:22 +00:00
}
}
public void DisableProcessing ( )
{
// Increase count
processingcount - - ;
if ( processingcount < 0 ) processingcount = 0 ;
// Turn off
if ( processor . Enabled & & ( processingcount = = 0 ) )
processor . Enabled = false ;
}
internal void StopProcessing ( )
{
// Turn off
processingcount = 0 ;
processor . Enabled = false ;
}
2016-08-29 10:06:16 +00:00
//mxd
internal void ResetClock ( )
{
Clock . Reset ( ) ;
lastupdatetime = 0 ;
// Let the mode know...
if ( General . Editing . Mode ! = null )
General . Editing . Mode . OnClockReset ( ) ;
}
2009-04-19 18:07:22 +00:00
// Processor event
private void processor_Tick ( object sender , EventArgs e )
{
2016-03-14 00:01:21 +00:00
long curtime = Clock . CurrentTime ;
long deltatime = curtime - lastupdatetime ;
2009-04-19 18:07:22 +00:00
lastupdatetime = curtime ;
2016-01-14 22:15:54 +00:00
if ( ( General . Map ! = null ) & & ( General . Editing . Mode ! = null ) )
2009-04-19 18:07:22 +00:00
{
2016-01-14 22:15:54 +00:00
// In exclusive mouse mode?
if ( mouseinput ! = null )
2010-08-22 11:36:09 +00:00
{
2016-01-14 22:15:54 +00:00
Vector2D deltamouse = mouseinput . Process ( ) ;
2010-08-22 11:36:09 +00:00
General . Plugins . OnEditMouseInput ( deltamouse ) ;
2009-04-19 18:07:22 +00:00
General . Editing . Mode . OnMouseInput ( deltamouse ) ;
2010-08-22 11:36:09 +00:00
}
2016-01-14 22:15:54 +00:00
// Process signal
2009-04-19 18:07:22 +00:00
General . Editing . Mode . OnProcess ( deltatime ) ;
2016-01-14 22:15:54 +00:00
}
2009-04-19 18:07:22 +00:00
}
#endregion
2009-07-21 05:51:13 +00:00
#region = = = = = = = = = = = = = = = = = = Dockers
2015-10-09 21:57:32 +00:00
2009-07-22 15:16:28 +00:00
// This adds a docker
public void AddDocker ( Docker d )
{
2014-10-09 19:29:17 +00:00
if ( dockerspanel . Contains ( d ) ) return ; //mxd
2016-04-15 14:24:18 +00:00
// Make sure the full name is set with the plugin name as prefix
Plugin plugin = General . Plugins . FindPluginByAssembly ( Assembly . GetCallingAssembly ( ) ) ;
d . MakeFullName ( plugin . Name . ToLowerInvariant ( ) ) ;
dockerspanel . Add ( d , false ) ;
}
//mxd. This also adds a docker
public void AddDocker ( Docker d , bool notify )
{
if ( dockerspanel . Contains ( d ) ) return ; //mxd
2009-07-22 15:16:28 +00:00
// Make sure the full name is set with the plugin name as prefix
Plugin plugin = General . Plugins . FindPluginByAssembly ( Assembly . GetCallingAssembly ( ) ) ;
d . MakeFullName ( plugin . Name . ToLowerInvariant ( ) ) ;
2016-04-15 14:24:18 +00:00
dockerspanel . Add ( d , notify ) ;
2009-07-22 15:16:28 +00:00
}
// This removes a docker
public bool RemoveDocker ( Docker d )
{
2015-10-09 21:57:32 +00:00
if ( ! dockerspanel . Contains ( d ) ) return true ; //mxd. Already removed/never added
2009-07-22 15:16:28 +00:00
// Make sure the full name is set with the plugin name as prefix
2015-10-09 21:57:32 +00:00
//Plugin plugin = General.Plugins.FindPluginByAssembly(Assembly.GetCallingAssembly());
//d.MakeFullName(plugin.Name.ToLowerInvariant());
2009-07-22 15:16:28 +00:00
2009-08-21 08:37:02 +00:00
// We must release all keys because the focus may be stolen when
// this was the selected docker (the previous docker is automatically selected)
ReleaseAllKeys ( ) ;
2009-07-22 15:16:28 +00:00
return dockerspanel . Remove ( d ) ;
}
// This selects a docker
public bool SelectDocker ( Docker d )
{
2015-10-09 21:57:32 +00:00
if ( ! dockerspanel . Contains ( d ) ) return false ; //mxd
2009-07-22 15:16:28 +00:00
// Make sure the full name is set with the plugin name as prefix
Plugin plugin = General . Plugins . FindPluginByAssembly ( Assembly . GetCallingAssembly ( ) ) ;
d . MakeFullName ( plugin . Name . ToLowerInvariant ( ) ) ;
2009-08-21 08:37:02 +00:00
// We must release all keys because the focus will be stolen
ReleaseAllKeys ( ) ;
2009-07-22 15:16:28 +00:00
return dockerspanel . SelectDocker ( d ) ;
}
// This selects the previous selected docker
public void SelectPreviousDocker ( )
{
2009-08-21 08:37:02 +00:00
// We must release all keys because the focus will be stolen
ReleaseAllKeys ( ) ;
2009-07-22 15:16:28 +00:00
dockerspanel . SelectPrevious ( ) ;
}
2009-07-21 05:51:13 +00:00
// Mouse enters dockers window
2009-07-21 13:42:36 +00:00
private void dockerspanel_MouseContainerEnter ( object sender , EventArgs e )
2009-07-21 05:51:13 +00:00
{
if ( General . Settings . CollapseDockers )
2009-07-22 21:15:14 +00:00
dockerscollapser . Start ( ) ;
2009-07-21 05:51:13 +00:00
dockerspanel . Expand ( ) ;
}
2009-07-21 13:42:36 +00:00
2009-07-22 21:15:14 +00:00
// Automatic collapsing
private void dockerscollapser_Tick ( object sender , EventArgs e )
2009-07-21 05:51:13 +00:00
{
if ( General . Settings . CollapseDockers )
2009-07-21 13:42:36 +00:00
{
2009-07-23 08:53:52 +00:00
if ( ! dockerspanel . IsFocused )
2009-07-22 21:15:14 +00:00
{
2009-07-23 08:53:52 +00:00
Point p = this . PointToClient ( Cursor . Position ) ;
Rectangle r = new Rectangle ( dockerspanel . Location , dockerspanel . Size ) ;
if ( ! r . IntersectsWith ( new Rectangle ( p , Size . Empty ) ) )
{
dockerspanel . Collapse ( ) ;
dockerscollapser . Stop ( ) ;
}
2009-07-22 21:15:14 +00:00
}
}
else
{
dockerscollapser . Stop ( ) ;
2009-07-21 13:42:36 +00:00
}
2009-07-21 05:51:13 +00:00
}
2009-07-21 13:42:36 +00:00
2009-07-21 15:15:38 +00:00
// User resizes the docker
private void dockerspanel_UserResize ( object sender , EventArgs e )
{
General . Settings . DockersWidth = dockerspanel . Width ;
2010-10-03 16:44:34 +00:00
2009-07-21 15:15:38 +00:00
if ( ! General . Settings . CollapseDockers )
2010-10-03 16:44:34 +00:00
{
2009-07-21 15:15:38 +00:00
dockersspace . Width = dockerspanel . Width ;
2010-10-03 16:44:34 +00:00
dockerspanel . Left = dockersspace . Left ;
}
2009-07-21 15:15:38 +00:00
}
2009-07-21 05:51:13 +00:00
#endregion
2012-04-17 19:13:47 +00:00
2015-07-01 23:09:34 +00:00
#region = = = = = = = = = = = = = = = = = = Updater ( mxd )
private delegate void UpdateAvailableCallback ( int remoterev , string changelog ) ;
2019-12-28 19:37:05 +00:00
internal void UpdateAvailable ( int remoterev , string changelog )
{
RunOnUIThread ( ( ) = > {
// Show the window
UpdateForm form = new UpdateForm ( remoterev , changelog ) ;
form . FormClosing + = delegate
{
// Update ignored revision number
General . Settings . IgnoredRemoteRevision = ( form . IgnoreThisUpdate ? remoterev : 0 ) ;
} ;
form . Show ( this ) ;
} ) ;
2015-07-01 23:09:34 +00:00
}
#endregion
2016-03-30 23:25:03 +00:00
#region = = = = = = = = = = = = = = = = = = Graphics ( mxd )
public SizeF MeasureString ( string text , Font font )
{
2019-07-16 18:37:18 +00:00
SizeF length ;
// Be thread safe
lock ( graphics )
{
length = graphics . MeasureString ( text , font ) ;
}
return length ;
2016-03-30 23:25:03 +00:00
}
2017-01-08 22:04:55 +00:00
public SizeF MeasureString ( string text , Font font , int width , StringFormat format )
{
2019-07-16 18:37:18 +00:00
SizeF length ;
// Be thread safe
lock ( graphics )
{
length = graphics . MeasureString ( text , font , width , format ) ;
}
return length ;
2017-01-08 22:04:55 +00:00
}
2016-03-30 23:25:03 +00:00
#endregion
2009-04-19 18:07:22 +00:00
}
2021-03-14 15:26:09 +00:00
}