ljhgfljiukghlkuyfgiyu
This commit is contained in:
@@ -31,6 +31,7 @@ namespace McBitFont {
|
|||||||
get { return Index < 0 ? Count : Count - Index - 1; }
|
get { return Index < 0 ? Count : Count - Index - 1; }
|
||||||
}
|
}
|
||||||
public bool HistoryAction { get; set; } = false;
|
public bool HistoryAction { get; set; } = false;
|
||||||
|
public bool Doing { get; set; } = false;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
public ChangeHistory(MainForm form, int depth = 100) {
|
public ChangeHistory(MainForm form, int depth = 100) {
|
||||||
@@ -43,6 +44,7 @@ namespace McBitFont {
|
|||||||
ResetIndices();
|
ResetIndices();
|
||||||
Add();
|
Add();
|
||||||
HistoryAction = false;
|
HistoryAction = false;
|
||||||
|
Doing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ResetIndices() {
|
private void ResetIndices() {
|
||||||
@@ -157,6 +159,7 @@ namespace McBitFont {
|
|||||||
|
|
||||||
// Add canvas change
|
// Add canvas change
|
||||||
public void Add(FrameMiniature f, bool useIndex = true) {
|
public void Add(FrameMiniature f, bool useIndex = true) {
|
||||||
|
if (Doing) return;
|
||||||
if (useIndex && CheckHistoryAction()) return;
|
if (useIndex && CheckHistoryAction()) return;
|
||||||
TruncateTail();
|
TruncateTail();
|
||||||
|
|
||||||
@@ -171,6 +174,7 @@ namespace McBitFont {
|
|||||||
|
|
||||||
// Add Font change
|
// Add Font change
|
||||||
public void Add(List<FrameMiniature> ff, bool useIndex = true) {
|
public void Add(List<FrameMiniature> ff, bool useIndex = true) {
|
||||||
|
if (Doing) return;
|
||||||
if (useIndex && CheckHistoryAction()) return;
|
if (useIndex && CheckHistoryAction()) return;
|
||||||
TruncateTail();
|
TruncateTail();
|
||||||
|
|
||||||
@@ -185,11 +189,13 @@ namespace McBitFont {
|
|||||||
timeline.Add(ChangeType.Font);
|
timeline.Add(ChangeType.Font);
|
||||||
Index++;
|
Index++;
|
||||||
fontIndex++;
|
fontIndex++;
|
||||||
|
Add(mainForm.f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add Frame selection change
|
// Add Frame selection change
|
||||||
public void Add(int code, bool useIndex = true) {
|
public void Add(int code, bool useIndex = true) {
|
||||||
|
if (Doing) return;
|
||||||
if (useIndex && CheckHistoryAction()) return;
|
if (useIndex && CheckHistoryAction()) return;
|
||||||
if (useIndex) {
|
if (useIndex) {
|
||||||
Add(mainForm.frames.Find(x => x.code == code));
|
Add(mainForm.frames.Find(x => x.code == code));
|
||||||
@@ -208,7 +214,8 @@ namespace McBitFont {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void Do(bool undo = true) {
|
private void Do(bool undo = true) {
|
||||||
ChangeType ct = timeline.ElementAt(Index + (undo ? 0 : 1));
|
Doing = true;
|
||||||
|
var ct = timeline.ElementAt(Index + (undo ? 0 : 1));
|
||||||
int dIndex = undo ? -1 : 1;
|
int dIndex = undo ? -1 : 1;
|
||||||
switch (ct) {
|
switch (ct) {
|
||||||
case ChangeType.Canvas:
|
case ChangeType.Canvas:
|
||||||
@@ -217,6 +224,12 @@ namespace McBitFont {
|
|||||||
break;
|
break;
|
||||||
case ChangeType.Font:
|
case ChangeType.Font:
|
||||||
Cursor.Current = Cursors.WaitCursor;
|
Cursor.Current = Cursors.WaitCursor;
|
||||||
|
string selItem = "";
|
||||||
|
int selCode = 0;
|
||||||
|
if (mainForm.miniList.SelectedItems.Count > 0) {
|
||||||
|
selItem = mainForm.miniList.SelectedItems[0].Name;
|
||||||
|
selCode = Convert.ToInt32(selItem);
|
||||||
|
}
|
||||||
fontIndex += dIndex;
|
fontIndex += dIndex;
|
||||||
mainForm.frames.Clear();
|
mainForm.frames.Clear();
|
||||||
mainForm.miniList.Clear();
|
mainForm.miniList.Clear();
|
||||||
@@ -225,6 +238,18 @@ namespace McBitFont {
|
|||||||
mainForm.frames.Add(CopyFrameSimple(f));
|
mainForm.frames.Add(CopyFrameSimple(f));
|
||||||
}
|
}
|
||||||
mainForm.FillFrameLists();
|
mainForm.FillFrameLists();
|
||||||
|
FrameMiniature fff;
|
||||||
|
if (selItem != "") {
|
||||||
|
var selection = mainForm.miniList.Items.Find(selItem, false);
|
||||||
|
if (selection.Length > 0) selection[0].Selected = true;
|
||||||
|
fff = mainForm.frames.Find(x => x.code == selCode);
|
||||||
|
} else {
|
||||||
|
mainForm.miniList.Items[0].Selected = true;
|
||||||
|
fff = mainForm.frames[0];
|
||||||
|
}
|
||||||
|
mainForm.f = mainForm.CopyFrame(fff);
|
||||||
|
mainForm.nudY.Value = mainForm.dotHeight = fff.height;
|
||||||
|
mainForm.nudX.Value = mainForm.dotWidth = fff.width;
|
||||||
Cursor.Current = Cursors.Default;
|
Cursor.Current = Cursors.Default;
|
||||||
break;
|
break;
|
||||||
case ChangeType.Frame:
|
case ChangeType.Frame:
|
||||||
@@ -233,14 +258,34 @@ namespace McBitFont {
|
|||||||
var s = selFrameChanges[selFrameIndex].ToString().PadLeft(3, '0');
|
var s = selFrameChanges[selFrameIndex].ToString().PadLeft(3, '0');
|
||||||
var sel = mainForm.miniList.Items.Find(s, false);
|
var sel = mainForm.miniList.Items.Find(s, false);
|
||||||
if (sel.Length > 0) sel[0].Selected = true;
|
if (sel.Length > 0) sel[0].Selected = true;
|
||||||
//if (undo) Undo(); else Redo();
|
break;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Index += dIndex;
|
Index += dIndex;
|
||||||
if (ct == ChangeType.Frame)
|
Doing = false;
|
||||||
if (undo) Undo(); else Redo();
|
// Frame select change + Canvas change workarounds
|
||||||
|
if (ct == ChangeType.Frame && undo) {
|
||||||
|
Undo();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Index < Count - 1) {
|
||||||
|
var nextctframe = timeline.ElementAt(Index + 1) == ChangeType.Frame;
|
||||||
|
if (ct == ChangeType.Canvas && !undo && nextctframe) {
|
||||||
|
Redo();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Font change + Canvas change workarounds
|
||||||
|
if (Index >= 0) {
|
||||||
|
var prevctfont = timeline.ElementAt(Index) == ChangeType.Font;
|
||||||
|
if (ct == ChangeType.Canvas && undo && prevctfont) {
|
||||||
|
Undo();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!undo && ct == ChangeType.Font)
|
||||||
|
Redo();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Undo last change
|
// Undo last change
|
||||||
|
4
McBitFont/Form1.Designer.cs
generated
4
McBitFont/Form1.Designer.cs
generated
@@ -1122,8 +1122,6 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private System.Windows.Forms.Panel dotPanel;
|
private System.Windows.Forms.Panel dotPanel;
|
||||||
private System.Windows.Forms.NumericUpDown nudX;
|
|
||||||
private System.Windows.Forms.NumericUpDown nudY;
|
|
||||||
private System.Windows.Forms.Label label1;
|
private System.Windows.Forms.Label label1;
|
||||||
private System.Windows.Forms.Label label2;
|
private System.Windows.Forms.Label label2;
|
||||||
private System.Windows.Forms.Label lblType;
|
private System.Windows.Forms.Label lblType;
|
||||||
@@ -1209,6 +1207,8 @@
|
|||||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
|
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
|
||||||
public System.Windows.Forms.ListView miniList;
|
public System.Windows.Forms.ListView miniList;
|
||||||
public System.Windows.Forms.ImageList ilMiniatures;
|
public System.Windows.Forms.ImageList ilMiniatures;
|
||||||
|
public System.Windows.Forms.NumericUpDown nudX;
|
||||||
|
public System.Windows.Forms.NumericUpDown nudY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -150,7 +150,7 @@ namespace McBitFont {
|
|||||||
return (int)(((ushort)lowPart) | (uint)(highPart << 16));
|
return (int)(((ushort)lowPart) | (uint)(highPart << 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
private FrameMiniature CopyFrame(FrameMiniature frame, bool clipboard = false) {
|
public FrameMiniature CopyFrame(FrameMiniature frame, bool clipboard = false) {
|
||||||
int width = chkRectSelect.Checked && clipboard ? selection2.X - selection1.X + 1 : frame.width;
|
int width = chkRectSelect.Checked && clipboard ? selection2.X - selection1.X + 1 : frame.width;
|
||||||
int height = chkRectSelect.Checked && clipboard ? selection2.Y - selection1.Y + 1 : frame.height;
|
int height = chkRectSelect.Checked && clipboard ? selection2.Y - selection1.Y + 1 : frame.height;
|
||||||
var ff = new FrameMiniature(frame.code, width, height);
|
var ff = new FrameMiniature(frame.code, width, height);
|
||||||
@@ -236,6 +236,7 @@ namespace McBitFont {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DotResize(dotWidth, (int)nudY.Value);
|
DotResize(dotWidth, (int)nudY.Value);
|
||||||
|
history.Add(frames);
|
||||||
Cursor.Current = Cursors.Default;
|
Cursor.Current = Cursors.Default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user