working on the brightness mode

This commit is contained in:
codeimp 2008-10-08 05:45:24 +00:00
parent 3117725c15
commit 1a6641f46b
12 changed files with 372 additions and 48 deletions

View file

@ -2,6 +2,8 @@
- Make sector gradient features
- Categories for control keys!
- Make error checking feature
- Make quick sector draw (square/circle) mode

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 B

View file

@ -155,6 +155,9 @@
<ItemGroup>
<None Include="Resources\treeview.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\BrightnessGradient.png" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View file

@ -47,20 +47,38 @@ namespace CodeImp.DoomBuilder.BuilderModes
public sealed class BrightnessMode : BaseClassicMode
{
#region ================== Enums
private enum ModifyMode : int
{
None,
Adjusting
}
#endregion
#region ================== Constants
#endregion
#region ================== Variables
// Highlighted item
private Sector highlighted;
// Interface
private bool editpressed;
// The methods GetSelected* and MarkSelected* on the MapSet do not
// retain the order in which items were selected.
// This list keeps in order while sectors are selected/deselected.
protected List<Sector> orderedselection;
// Labels
private Dictionary<Sector, TextLabel[]> labels;
// Modifying
private ModifyMode mode;
#endregion
@ -73,6 +91,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Constructor
public BrightnessMode()
{
// Make ordered selection list
orderedselection = new List<Sector>();
}
// Disposer
@ -141,22 +161,39 @@ namespace CodeImp.DoomBuilder.BuilderModes
// This highlights a new item
protected void Highlight(Sector s)
{
// Update display
if(renderer.StartPlotter(false))
// Highlight actually changes?
if(s != highlighted)
{
// Undraw previous highlight
if((highlighted != null) && !highlighted.IsDisposed)
renderer.PlotSector(highlighted);
// Set new highlight
highlighted = s;
// Render highlighted item
if((highlighted != null) && !highlighted.IsDisposed)
renderer.PlotSector(highlighted, General.Colors.Highlight);
// Done
renderer.Finish();
// Update display
if(renderer.StartPlotter(false))
{
if((highlighted != null) && !highlighted.IsDisposed)
{
// Undraw previous highlight
renderer.PlotSector(highlighted);
// Change label color
TextLabel[] labelarray = labels[highlighted];
foreach(TextLabel l in labelarray) l.Color = General.Colors.Selection;
}
// Set new highlight
highlighted = s;
if((highlighted != null) && !highlighted.IsDisposed)
{
// Render highlighted item
renderer.PlotSector(highlighted, General.Colors.Highlight);
// Change label color
TextLabel[] labelarray = labels[highlighted];
foreach(TextLabel l in labelarray) l.Color = General.Colors.Highlight;
}
renderer.Finish();
}
UpdateOverlay();
renderer.Present();
}
@ -166,6 +203,66 @@ namespace CodeImp.DoomBuilder.BuilderModes
else
General.Interface.HideInfo();
}
// This selectes or deselects a sector
protected void SelectSector(Sector s, bool selectstate, bool update)
{
bool selectionchanged = false;
if(!s.IsDisposed)
{
// Select the sector?
if(selectstate && !s.Selected)
{
orderedselection.Add(s);
s.Selected = true;
selectionchanged = true;
// Setup labels
TextLabel[] labelarray = labels[s];
foreach(TextLabel l in labelarray)
{
l.Text = orderedselection.Count.ToString();
l.Color = General.Colors.Selection;
}
}
// Deselect the sector?
else if(!selectstate && s.Selected)
{
orderedselection.Remove(s);
s.Selected = false;
selectionchanged = true;
// Clear labels
TextLabel[] labelarray = labels[s];
foreach(TextLabel l in labelarray) l.Text = "";
}
// Selection changed?
if(selectionchanged)
{
// Make update lines selection
foreach(Sidedef sd in s.Sidedefs)
{
bool front, back;
if(sd.Line.Front != null) front = sd.Line.Front.Sector.Selected; else front = false;
if(sd.Line.Back != null) back = sd.Line.Back.Sector.Selected; else back = false;
sd.Line.Selected = front | back;
}
}
if(update)
{
UpdateOverlay();
renderer.Present();
}
}
else
{
// Remove from list
orderedselection.Remove(s);
}
}
#endregion
@ -175,11 +272,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
public override void OnEngage()
{
base.OnEngage();
// No selection
General.Map.Map.ClearAllMarks(false);
General.Map.Map.ClearAllSelected();
// Add toolbar button
General.Interface.AddButton(BuilderPlug.Me.MenusForm.MakeGradientBrightness);
// Make custom presentation
CustomPresentation p = new CustomPresentation();
p.AddLayer(new PresentLayer(RendererLayer.Background, BlendingMode.Mask));
@ -205,10 +301,62 @@ namespace CodeImp.DoomBuilder.BuilderModes
labelarray[i].AlignY = TextAlignmentY.Middle;
labelarray[i].Scale = 14f;
labelarray[i].Color = General.Colors.Highlight;
labelarray[i].Backcolor = General.Colors.Background;
labelarray[i].Backcolor = General.Colors.Background.WithAlpha(80);
}
labels.Add(s, labelarray);
}
// Convert geometry selection to sectors only
General.Map.Map.ClearAllMarks(false);
General.Map.Map.MarkSelectedVertices(true, true);
ICollection<Linedef> lines = General.Map.Map.LinedefsFromMarkedVertices(false, true, false);
foreach(Linedef l in lines) l.Selected = true;
General.Map.Map.ClearMarkedSectors(true);
foreach(Linedef l in General.Map.Map.Linedefs)
{
if(!l.Selected)
{
if(l.Front != null) l.Front.Sector.Marked = false;
if(l.Back != null) l.Back.Sector.Marked = false;
}
}
General.Map.Map.ClearAllSelected();
foreach(Sector s in General.Map.Map.Sectors)
{
if(s.Marked)
{
s.Selected = true;
foreach(Sidedef sd in s.Sidedefs) sd.Line.Selected = true;
}
}
// Fill the list with selected sectors (these are not in order, but we have no other choice)
ICollection<Sector> selectedsectors = General.Map.Map.GetSelectedSectors(true);
General.Map.Map.ClearSelectedSectors();
foreach(Sector s in selectedsectors) SelectSector(s, true, false);
}
// When disengaged
public override void OnDisengage()
{
base.OnDisengage();
// Remove toolbar button
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.MakeGradientBrightness);
// Going to EditSelectionMode?
if(General.Map.NewMode is EditSelectionMode)
{
// No selection made? But we have a highlight!
if((General.Map.Map.GetSelectedSectors(true).Count == 0) && (highlighted != null))
{
// Make the highlight the selection
SelectSector(highlighted, true, false);
}
}
// Hide highlight info
General.Interface.HideInfo();
}
// This redraws the display
@ -292,22 +440,140 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Selecting with mouse
protected override void OnSelect()
{
base.OnSelect();
// Sector highlighted?
// Item highlighted?
if((highlighted != null) && !highlighted.IsDisposed)
{
// Show index on label
for(int i = 0; i < highlighted.Triangles.IslandVertices.Count; i++)
// Flip selection
SelectSector(highlighted, !highlighted.Selected, true);
// Update display
if(renderer.StartPlotter(false))
{
labels[highlighted][i].Text = highlighted.Index.ToString();
// Redraw highlight to show selection
renderer.PlotSector(highlighted);
renderer.Finish();
renderer.Present();
}
UpdateOverlay();
}
else
{
// Start making a selection
StartMultiSelection();
}
base.OnSelect();
}
// End selection
protected override void OnEndSelect()
{
// Not stopping from multiselection?
if(!selecting)
{
// Item highlighted?
if((highlighted != null) && !highlighted.IsDisposed)
{
// Update display
if(renderer.StartPlotter(false))
{
// Render highlighted item
renderer.PlotSector(highlighted, General.Colors.Highlight);
renderer.Finish();
}
// Update overlay
TextLabel[] labelarray = labels[highlighted];
foreach(TextLabel l in labelarray) l.Color = General.Colors.Highlight;
UpdateOverlay();
renderer.Present();
}
}
base.OnEndSelect();
}
// This is called wheh selection ends
protected override void OnEndMultiSelection()
{
// Go for all lines
foreach(Linedef l in General.Map.Map.Linedefs)
{
l.Selected = ((l.Start.Position.x >= selectionrect.Left) &&
(l.Start.Position.y >= selectionrect.Top) &&
(l.Start.Position.x <= selectionrect.Right) &&
(l.Start.Position.y <= selectionrect.Bottom) &&
(l.End.Position.x >= selectionrect.Left) &&
(l.End.Position.y >= selectionrect.Top) &&
(l.End.Position.x <= selectionrect.Right) &&
(l.End.Position.y <= selectionrect.Bottom));
}
// Go for all sectors
foreach(Sector s in General.Map.Map.Sectors)
{
// Go for all sidedefs
bool allselected = true;
foreach(Sidedef sd in s.Sidedefs)
{
if(!sd.Line.Selected)
{
allselected = false;
break;
}
}
// Sector completely selected?
SelectSector(s, allselected, false);
}
// Make sure all linedefs reflect selected sectors
foreach(Sector s in General.Map.Map.Sectors)
SelectSector(s, s.Selected, false);
base.OnEndMultiSelection();
General.Interface.RedrawDisplay();
}
// This is called when the selection is updated
protected override void OnUpdateMultiSelection()
{
base.OnUpdateMultiSelection();
// Render selection
UpdateOverlay();
if(renderer.StartOverlay(false))
{
RenderMultiSelection();
renderer.Finish();
renderer.Present();
}
}
#endregion
#region ================== Actions
[BeginAction("gradientbrightness")]
public void MakeGradientBrightness()
{
}
// This clears the selection
[BeginAction("clearselection", BaseAction = true)]
public void ClearSelection()
{
// Clear selection
General.Map.Map.ClearAllSelected();
orderedselection.Clear();
// Clear labels
foreach(TextLabel[] labelarray in labels.Values)
foreach(TextLabel l in labelarray) l.Text = "";
// Redraw
General.Interface.RedrawDisplay();
}
#endregion
}
}

View file

@ -77,10 +77,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
// Make ordered selection list
orderedselection = new List<Sector>();
// Fill the list with selected sectors (these are not in order, but we have no other choice)
ICollection<Sector> selectedsectors = General.Map.Map.GetSelectedSectors(true);
foreach(Sector s in selectedsectors) orderedselection.Add(s);
}
// Disposer
@ -285,7 +281,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
s.Selected = true;
foreach(Sidedef sd in s.Sidedefs) sd.Line.Selected = true;
}
}
}
// Fill the list with selected sectors (these are not in order, but we have no other choice)
ICollection<Sector> selectedsectors = General.Map.Map.GetSelectedSectors(true);
foreach(Sector s in selectedsectors) orderedselection.Add(s);
}
// Mode disengages
@ -785,6 +785,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
// Clear selection
General.Map.Map.ClearAllSelected();
orderedselection.Clear();
// Redraw
General.Interface.RedrawDisplay();

View file

@ -43,8 +43,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.thingsmenu = new System.Windows.Forms.ToolStripMenuItem();
this.rotatethingscwitem = new System.Windows.Forms.ToolStripMenuItem();
this.rotatethingsccwitem = new System.Windows.Forms.ToolStripMenuItem();
this.toolstrip = new System.Windows.Forms.ToolStrip();
this.globalstrip = new System.Windows.Forms.ToolStrip();
this.manualstrip = new System.Windows.Forms.ToolStrip();
this.buttonbrightnessgradient = new System.Windows.Forms.ToolStripButton();
this.menustrip.SuspendLayout();
this.manualstrip.SuspendLayout();
this.SuspendLayout();
//
// menustrip
@ -168,19 +171,41 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.rotatethingsccwitem.Size = new System.Drawing.Size(204, 22);
this.rotatethingsccwitem.Text = "Rotate Counterclockwise";
//
// toolstrip
// globalstrip
//
this.toolstrip.Location = new System.Drawing.Point(0, 24);
this.toolstrip.Name = "toolstrip";
this.toolstrip.Size = new System.Drawing.Size(423, 25);
this.toolstrip.TabIndex = 1;
this.toolstrip.Text = "toolstrip";
this.globalstrip.Location = new System.Drawing.Point(0, 24);
this.globalstrip.Name = "globalstrip";
this.globalstrip.Size = new System.Drawing.Size(423, 25);
this.globalstrip.TabIndex = 1;
this.globalstrip.Text = "toolstrip";
//
// manualstrip
//
this.manualstrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.buttonbrightnessgradient});
this.manualstrip.Location = new System.Drawing.Point(0, 49);
this.manualstrip.Name = "manualstrip";
this.manualstrip.Size = new System.Drawing.Size(423, 25);
this.manualstrip.TabIndex = 2;
this.manualstrip.Text = "toolStrip1";
//
// buttonbrightnessgradient
//
this.buttonbrightnessgradient.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.buttonbrightnessgradient.Image = global::CodeImp.DoomBuilder.BuilderModes.Properties.Resources.BrightnessGradient;
this.buttonbrightnessgradient.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
this.buttonbrightnessgradient.ImageTransparentColor = System.Drawing.Color.Magenta;
this.buttonbrightnessgradient.Name = "buttonbrightnessgradient";
this.buttonbrightnessgradient.Size = new System.Drawing.Size(23, 22);
this.buttonbrightnessgradient.Tag = "gradientbrightness";
this.buttonbrightnessgradient.Text = "Make Brightness Gradient";
//
// MenusForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(423, 248);
this.Controls.Add(this.toolstrip);
this.Controls.Add(this.manualstrip);
this.Controls.Add(this.globalstrip);
this.Controls.Add(this.menustrip);
this.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
@ -193,6 +218,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.Text = "MenusForm";
this.menustrip.ResumeLayout(false);
this.menustrip.PerformLayout();
this.manualstrip.ResumeLayout(false);
this.manualstrip.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@ -215,6 +242,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
private System.Windows.Forms.ToolStripMenuItem rotatethingsccwitem;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem3;
private System.Windows.Forms.ToolStripMenuItem splitlinedefsitem;
private System.Windows.Forms.ToolStrip toolstrip;
private System.Windows.Forms.ToolStrip globalstrip;
private System.Windows.Forms.ToolStrip manualstrip;
private System.Windows.Forms.ToolStripButton buttonbrightnessgradient;
}
}

View file

@ -53,6 +53,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public ToolStripMenuItem LinedefsMenu { get { return linedefsmenu; } }
public ToolStripMenuItem SectorsMenu { get { return sectorsmenu; } }
public ToolStripMenuItem ThingsMenu { get { return thingsmenu; } }
public ToolStripButton MakeGradientBrightness { get { return buttonbrightnessgradient; } }
#endregion
@ -69,8 +70,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
for(int i = 0; i < menustrip.Items.Count; i++) menus[i] = menustrip.Items[i];
// List all buttons
buttons = new ToolStripItem[toolstrip.Items.Count];
for(int i = 0; i < toolstrip.Items.Count; i++) buttons[i] = toolstrip.Items[i];
buttons = new ToolStripItem[globalstrip.Items.Count];
for(int i = 0; i < globalstrip.Items.Count; i++) buttons[i] = globalstrip.Items[i];
}
#endregion

View file

@ -120,7 +120,10 @@
<metadata name="menustrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="toolstrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="globalstrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>118, 17</value>
</metadata>
<metadata name="manualstrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>210, 17</value>
</metadata>
</root>

View file

@ -60,6 +60,13 @@ namespace CodeImp.DoomBuilder.BuilderModes.Properties {
}
}
internal static System.Drawing.Bitmap BrightnessGradient {
get {
object obj = ResourceManager.GetObject("BrightnessGradient", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap treeview {
get {
object obj = ResourceManager.GetObject("treeview", resourceCulture);

View file

@ -118,6 +118,9 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="BrightnessGradient" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\BrightnessGradient.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="treeview" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\treeview.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>

View file

@ -208,3 +208,12 @@ editselectionmode
allowmouse = true;
allowscroll = true;
}
gradientbrightness
{
title = "Brightness: Make Gradient";
description = "Creates a brightness gradient over all selected sectors from the first to the last selected sector.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 B