diff --git a/Gola2/CSDiv.cs b/Gola2/CSDiv.cs
index 96020a2..2c96cf1 100644
--- a/Gola2/CSDiv.cs
+++ b/Gola2/CSDiv.cs
@@ -107,6 +107,7 @@
acts = actors.ToArray();
using (Graphics g = Graphics.FromImage(bmp))
{
+ g.SmoothingMode = SmoothingMode.AntiAlias;
g.Clear(Color.Transparent);
foreach (CSDivActor a in acts)
if (a.Visible)
@@ -128,6 +129,8 @@
public static void Start()
{
+ if (Active)
+ return;
CanvasInit();
timer = new Timer(new TimerCallback(Execute), null, 0, 1000 / fps);
canvas.Show();
@@ -135,6 +138,8 @@
public static void Stop()
{
+ if (!Active)
+ return;
if (timer != null)
timer.Dispose();
timer = null;
@@ -153,6 +158,7 @@
}
public static Rectangle Bounds => canvas.CanvasBounds;
+ public static bool Active => timer != null;
#region Extension
#endregion
diff --git a/Gola2/CreatureEditor.Designer.cs b/Gola2/CreatureEditor.Designer.cs
new file mode 100644
index 0000000..efe629e
--- /dev/null
+++ b/Gola2/CreatureEditor.Designer.cs
@@ -0,0 +1,466 @@
+namespace Gola2
+{
+ partial class CreatureEditor
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ this.label1 = new System.Windows.Forms.Label();
+ this.tbCName = new System.Windows.Forms.TextBox();
+ this.label2 = new System.Windows.Forms.Label();
+ this.label3 = new System.Windows.Forms.Label();
+ this.nudX = new System.Windows.Forms.NumericUpDown();
+ this.nudY = new System.Windows.Forms.NumericUpDown();
+ this.label4 = new System.Windows.Forms.Label();
+ this.nudZ = new System.Windows.Forms.NumericUpDown();
+ this.label5 = new System.Windows.Forms.Label();
+ this.label6 = new System.Windows.Forms.Label();
+ this.nudSize = new System.Windows.Forms.NumericUpDown();
+ this.label7 = new System.Windows.Forms.Label();
+ this.pColor = new System.Windows.Forms.Panel();
+ this.cbType = new System.Windows.Forms.ComboBox();
+ this.btCellAdd = new System.Windows.Forms.Button();
+ this.btCellRemove = new System.Windows.Forms.Button();
+ this.btCreatureRemove = new System.Windows.Forms.Button();
+ this.btCreatureAdd = new System.Windows.Forms.Button();
+ this.lbCreatures = new System.Windows.Forms.ListBox();
+ this.lbCells = new System.Windows.Forms.ListBox();
+ this.label8 = new System.Windows.Forms.Label();
+ this.cmsCreatures = new System.Windows.Forms.ContextMenuStrip(this.components);
+ this.copyCreatureToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.pasteCreatureToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.pasteCreatureAsNewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.pRender = new Gola2.PanelDBuf();
+ this.btReset = new System.Windows.Forms.Button();
+ this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
+ this.bounceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ ((System.ComponentModel.ISupportInitialize)(this.nudX)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.nudY)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.nudZ)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.nudSize)).BeginInit();
+ this.cmsCreatures.SuspendLayout();
+ this.pRender.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(294, 15);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(79, 13);
+ this.label1.TabIndex = 3;
+ this.label1.Text = "Creature name:";
+ //
+ // tbCName
+ //
+ this.tbCName.Location = new System.Drawing.Point(379, 12);
+ this.tbCName.MaxLength = 512;
+ this.tbCName.Name = "tbCName";
+ this.tbCName.Size = new System.Drawing.Size(193, 20);
+ this.tbCName.TabIndex = 4;
+ this.tbCName.TextChanged += new System.EventHandler(this.tbCName_TextChanged);
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(294, 40);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(47, 13);
+ this.label2.TabIndex = 5;
+ this.label2.Text = "Position:";
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(306, 60);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(17, 13);
+ this.label3.TabIndex = 6;
+ this.label3.Text = "X:";
+ //
+ // nudX
+ //
+ this.nudX.DecimalPlaces = 2;
+ this.nudX.Increment = new decimal(new int[] {
+ 1,
+ 0,
+ 0,
+ 131072});
+ this.nudX.Location = new System.Drawing.Point(324, 58);
+ this.nudX.Maximum = new decimal(new int[] {
+ 64,
+ 0,
+ 0,
+ 0});
+ this.nudX.Minimum = new decimal(new int[] {
+ 64,
+ 0,
+ 0,
+ -2147483648});
+ this.nudX.Name = "nudX";
+ this.nudX.Size = new System.Drawing.Size(60, 20);
+ this.nudX.TabIndex = 7;
+ this.nudX.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+ this.nudX.ValueChanged += new System.EventHandler(this.PositionChanged);
+ //
+ // nudY
+ //
+ this.nudY.DecimalPlaces = 2;
+ this.nudY.Increment = new decimal(new int[] {
+ 1,
+ 0,
+ 0,
+ 131072});
+ this.nudY.Location = new System.Drawing.Point(324, 84);
+ this.nudY.Maximum = new decimal(new int[] {
+ 64,
+ 0,
+ 0,
+ 0});
+ this.nudY.Minimum = new decimal(new int[] {
+ 64,
+ 0,
+ 0,
+ -2147483648});
+ this.nudY.Name = "nudY";
+ this.nudY.Size = new System.Drawing.Size(60, 20);
+ this.nudY.TabIndex = 9;
+ this.nudY.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+ this.nudY.ValueChanged += new System.EventHandler(this.PositionChanged);
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Location = new System.Drawing.Point(306, 86);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(17, 13);
+ this.label4.TabIndex = 8;
+ this.label4.Text = "Y:";
+ //
+ // nudZ
+ //
+ this.nudZ.DecimalPlaces = 2;
+ this.nudZ.Increment = new decimal(new int[] {
+ 1,
+ 0,
+ 0,
+ 131072});
+ this.nudZ.Location = new System.Drawing.Point(324, 110);
+ this.nudZ.Maximum = new decimal(new int[] {
+ 64,
+ 0,
+ 0,
+ 0});
+ this.nudZ.Minimum = new decimal(new int[] {
+ 64,
+ 0,
+ 0,
+ -2147483648});
+ this.nudZ.Name = "nudZ";
+ this.nudZ.Size = new System.Drawing.Size(60, 20);
+ this.nudZ.TabIndex = 11;
+ this.nudZ.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+ this.nudZ.ValueChanged += new System.EventHandler(this.PositionChanged);
+ //
+ // label5
+ //
+ this.label5.AutoSize = true;
+ this.label5.Location = new System.Drawing.Point(306, 112);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(17, 13);
+ this.label5.TabIndex = 10;
+ this.label5.Text = "Z:";
+ //
+ // label6
+ //
+ this.label6.AutoSize = true;
+ this.label6.Location = new System.Drawing.Point(390, 60);
+ this.label6.Name = "label6";
+ this.label6.Size = new System.Drawing.Size(30, 13);
+ this.label6.TabIndex = 12;
+ this.label6.Text = "Size:";
+ //
+ // nudSize
+ //
+ this.nudSize.DecimalPlaces = 1;
+ this.nudSize.Location = new System.Drawing.Point(430, 58);
+ this.nudSize.Maximum = new decimal(new int[] {
+ 64,
+ 0,
+ 0,
+ 0});
+ this.nudSize.Name = "nudSize";
+ this.nudSize.Size = new System.Drawing.Size(51, 20);
+ this.nudSize.TabIndex = 13;
+ this.nudSize.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+ this.nudSize.Value = new decimal(new int[] {
+ 5,
+ 0,
+ 0,
+ 0});
+ this.nudSize.ValueChanged += new System.EventHandler(this.PositionChanged);
+ //
+ // label7
+ //
+ this.label7.AutoSize = true;
+ this.label7.Location = new System.Drawing.Point(390, 86);
+ this.label7.Name = "label7";
+ this.label7.Size = new System.Drawing.Size(34, 13);
+ this.label7.TabIndex = 14;
+ this.label7.Text = "Color:";
+ //
+ // pColor
+ //
+ this.pColor.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
+ this.pColor.Location = new System.Drawing.Point(430, 84);
+ this.pColor.Name = "pColor";
+ this.pColor.Size = new System.Drawing.Size(51, 20);
+ this.pColor.TabIndex = 15;
+ this.pColor.Click += new System.EventHandler(this.pColor_Click);
+ //
+ // cbType
+ //
+ this.cbType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.cbType.FormattingEnabled = true;
+ this.cbType.Location = new System.Drawing.Point(430, 109);
+ this.cbType.Name = "cbType";
+ this.cbType.Size = new System.Drawing.Size(141, 21);
+ this.cbType.TabIndex = 17;
+ //
+ // btCellAdd
+ //
+ this.btCellAdd.Location = new System.Drawing.Point(577, 136);
+ this.btCellAdd.Name = "btCellAdd";
+ this.btCellAdd.Size = new System.Drawing.Size(24, 24);
+ this.btCellAdd.TabIndex = 18;
+ this.btCellAdd.Text = "+";
+ this.btCellAdd.UseVisualStyleBackColor = true;
+ this.btCellAdd.Click += new System.EventHandler(this.btCellAdd_Click);
+ //
+ // btCellRemove
+ //
+ this.btCellRemove.Location = new System.Drawing.Point(577, 166);
+ this.btCellRemove.Name = "btCellRemove";
+ this.btCellRemove.Size = new System.Drawing.Size(24, 24);
+ this.btCellRemove.TabIndex = 19;
+ this.btCellRemove.Text = "-";
+ this.btCellRemove.UseVisualStyleBackColor = true;
+ this.btCellRemove.Click += new System.EventHandler(this.btCellRemove_Click);
+ //
+ // btCreatureRemove
+ //
+ this.btCreatureRemove.Location = new System.Drawing.Point(264, 324);
+ this.btCreatureRemove.Name = "btCreatureRemove";
+ this.btCreatureRemove.Size = new System.Drawing.Size(24, 24);
+ this.btCreatureRemove.TabIndex = 21;
+ this.btCreatureRemove.Text = "-";
+ this.btCreatureRemove.UseVisualStyleBackColor = true;
+ this.btCreatureRemove.Click += new System.EventHandler(this.btCreatureRemove_Click);
+ //
+ // btCreatureAdd
+ //
+ this.btCreatureAdd.Location = new System.Drawing.Point(264, 294);
+ this.btCreatureAdd.Name = "btCreatureAdd";
+ this.btCreatureAdd.Size = new System.Drawing.Size(24, 24);
+ this.btCreatureAdd.TabIndex = 20;
+ this.btCreatureAdd.Text = "+";
+ this.btCreatureAdd.UseVisualStyleBackColor = true;
+ this.btCreatureAdd.Click += new System.EventHandler(this.btCreatureAdd_Click);
+ //
+ // lbCreatures
+ //
+ this.lbCreatures.ContextMenuStrip = this.cmsCreatures;
+ this.lbCreatures.FormattingEnabled = true;
+ this.lbCreatures.IntegralHeight = false;
+ this.lbCreatures.Location = new System.Drawing.Point(12, 294);
+ this.lbCreatures.Name = "lbCreatures";
+ this.lbCreatures.Size = new System.Drawing.Size(246, 115);
+ this.lbCreatures.TabIndex = 22;
+ this.lbCreatures.SelectedValueChanged += new System.EventHandler(this.lbCreatures_SelectedValueChanged);
+ //
+ // lbCells
+ //
+ this.lbCells.FormattingEnabled = true;
+ this.lbCells.IntegralHeight = false;
+ this.lbCells.Location = new System.Drawing.Point(294, 136);
+ this.lbCells.Name = "lbCells";
+ this.lbCells.Size = new System.Drawing.Size(277, 273);
+ this.lbCells.TabIndex = 23;
+ this.lbCells.SelectedValueChanged += new System.EventHandler(this.lbCells_SelectedValueChanged);
+ //
+ // label8
+ //
+ this.label8.AutoSize = true;
+ this.label8.Location = new System.Drawing.Point(390, 112);
+ this.label8.Name = "label8";
+ this.label8.Size = new System.Drawing.Size(34, 13);
+ this.label8.TabIndex = 24;
+ this.label8.Text = "Type:";
+ //
+ // cmsCreatures
+ //
+ this.cmsCreatures.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.bounceToolStripMenuItem,
+ this.toolStripSeparator1,
+ this.copyCreatureToolStripMenuItem,
+ this.pasteCreatureToolStripMenuItem,
+ this.pasteCreatureAsNewToolStripMenuItem});
+ this.cmsCreatures.Name = "cmsCreatures";
+ this.cmsCreatures.Size = new System.Drawing.Size(188, 120);
+ //
+ // copyCreatureToolStripMenuItem
+ //
+ this.copyCreatureToolStripMenuItem.Name = "copyCreatureToolStripMenuItem";
+ this.copyCreatureToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
+ this.copyCreatureToolStripMenuItem.Text = "Copy creature";
+ this.copyCreatureToolStripMenuItem.Click += new System.EventHandler(this.copyCreatureToolStripMenuItem_Click);
+ //
+ // pasteCreatureToolStripMenuItem
+ //
+ this.pasteCreatureToolStripMenuItem.Name = "pasteCreatureToolStripMenuItem";
+ this.pasteCreatureToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
+ this.pasteCreatureToolStripMenuItem.Text = "Paste creature";
+ this.pasteCreatureToolStripMenuItem.Click += new System.EventHandler(this.pasteCreatureToolStripMenuItem_Click);
+ //
+ // pasteCreatureAsNewToolStripMenuItem
+ //
+ this.pasteCreatureAsNewToolStripMenuItem.Name = "pasteCreatureAsNewToolStripMenuItem";
+ this.pasteCreatureAsNewToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
+ this.pasteCreatureAsNewToolStripMenuItem.Text = "Paste creature as new";
+ this.pasteCreatureAsNewToolStripMenuItem.Click += new System.EventHandler(this.pasteCreatureAsNewToolStripMenuItem_Click);
+ //
+ // pRender
+ //
+ this.pRender.Controls.Add(this.btReset);
+ this.pRender.Location = new System.Drawing.Point(12, 12);
+ this.pRender.Name = "pRender";
+ this.pRender.Size = new System.Drawing.Size(276, 276);
+ this.pRender.TabIndex = 0;
+ this.pRender.Paint += new System.Windows.Forms.PaintEventHandler(this.pRender_Paint);
+ this.pRender.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pRender_MouseDown);
+ this.pRender.MouseLeave += new System.EventHandler(this.pRender_MouseLeave);
+ this.pRender.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pRender_MouseMove);
+ this.pRender.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pRender_MouseUp);
+ //
+ // btReset
+ //
+ this.btReset.Location = new System.Drawing.Point(249, 249);
+ this.btReset.Name = "btReset";
+ this.btReset.Size = new System.Drawing.Size(24, 24);
+ this.btReset.TabIndex = 0;
+ this.btReset.Text = "/";
+ this.btReset.UseVisualStyleBackColor = true;
+ this.btReset.Click += new System.EventHandler(this.btReset_Click);
+ //
+ // toolStripSeparator1
+ //
+ this.toolStripSeparator1.Name = "toolStripSeparator1";
+ this.toolStripSeparator1.Size = new System.Drawing.Size(184, 6);
+ //
+ // bounceToolStripMenuItem
+ //
+ this.bounceToolStripMenuItem.Name = "bounceToolStripMenuItem";
+ this.bounceToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
+ this.bounceToolStripMenuItem.Text = "Bounce";
+ this.bounceToolStripMenuItem.Click += new System.EventHandler(this.bounceToolStripMenuItem_Click);
+ //
+ // CreatureEditor
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(607, 421);
+ this.Controls.Add(this.label8);
+ this.Controls.Add(this.lbCells);
+ this.Controls.Add(this.lbCreatures);
+ this.Controls.Add(this.btCreatureRemove);
+ this.Controls.Add(this.btCreatureAdd);
+ this.Controls.Add(this.btCellRemove);
+ this.Controls.Add(this.btCellAdd);
+ this.Controls.Add(this.cbType);
+ this.Controls.Add(this.pColor);
+ this.Controls.Add(this.label7);
+ this.Controls.Add(this.nudSize);
+ this.Controls.Add(this.label6);
+ this.Controls.Add(this.nudZ);
+ this.Controls.Add(this.label5);
+ this.Controls.Add(this.nudY);
+ this.Controls.Add(this.label4);
+ this.Controls.Add(this.nudX);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.tbCName);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.pRender);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
+ this.Name = "CreatureEditor";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+ this.Text = "CreatureEditor";
+ this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.CreatureEditor_FormClosed);
+ ((System.ComponentModel.ISupportInitialize)(this.nudX)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.nudY)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.nudZ)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.nudSize)).EndInit();
+ this.cmsCreatures.ResumeLayout(false);
+ this.pRender.ResumeLayout(false);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private PanelDBuf pRender;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.TextBox tbCName;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.NumericUpDown nudX;
+ private System.Windows.Forms.NumericUpDown nudY;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.NumericUpDown nudZ;
+ private System.Windows.Forms.Label label5;
+ private System.Windows.Forms.Label label6;
+ private System.Windows.Forms.NumericUpDown nudSize;
+ private System.Windows.Forms.Label label7;
+ private System.Windows.Forms.Panel pColor;
+ private System.Windows.Forms.ComboBox cbType;
+ private System.Windows.Forms.Button btCellAdd;
+ private System.Windows.Forms.Button btCellRemove;
+ private System.Windows.Forms.Button btCreatureRemove;
+ private System.Windows.Forms.Button btCreatureAdd;
+ private System.Windows.Forms.ListBox lbCreatures;
+ private System.Windows.Forms.ListBox lbCells;
+ private System.Windows.Forms.Button btReset;
+ private System.Windows.Forms.Label label8;
+ private System.Windows.Forms.ContextMenuStrip cmsCreatures;
+ private System.Windows.Forms.ToolStripMenuItem copyCreatureToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem pasteCreatureToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem pasteCreatureAsNewToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem bounceToolStripMenuItem;
+ private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
+ }
+}
\ No newline at end of file
diff --git a/Gola2/CreatureEditor.cs b/Gola2/CreatureEditor.cs
new file mode 100644
index 0000000..6ff17f7
--- /dev/null
+++ b/Gola2/CreatureEditor.cs
@@ -0,0 +1,321 @@
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Windows.Forms;
+
+namespace Gola2
+{
+ public partial class CreatureEditor : Form
+ {
+ private Mini3D mini = new Mini3D();
+ private Pen ballPen = new Pen(Color.FromArgb(100, 200, 200, 200), 0.24f);
+ private bool loading = false;
+ private Vector3 rotation;
+ private bool rotating;
+ private Point mousePos;
+ private ColorDialog colorPicker = new ColorDialog();
+
+ private CreatureEditor()
+ {
+ InitializeComponent();
+ loading = true;
+ try
+ {
+ lbCreatures.Items.AddRange(CreatureDB.Creatures.ToArray());
+ }
+ finally
+ {
+ loading = false;
+ }
+ if (lbCreatures.Items.Count > 0)
+ lbCreatures.SelectedIndex = 0;
+ else
+ UIStatus();
+ }
+
+ public static void Execute()
+ {
+ using (CreatureEditor editor = new CreatureEditor())
+ editor.ShowDialog();
+ }
+
+ private void UIStatus()
+ {
+ bool selCreature = lbCreatures.SelectedItem != null;
+ btCreatureRemove.Enabled = selCreature;
+ btCellAdd.Enabled = selCreature;
+ tbCName.Enabled = selCreature;
+ copyCreatureToolStripMenuItem.Enabled = selCreature;
+ pasteCreatureToolStripMenuItem.Enabled = selCreature;
+ bounceToolStripMenuItem.Enabled = selCreature;
+ bool selCell = selCreature && lbCells.SelectedItem != null;
+ btCellRemove.Enabled = selCell;
+ nudX.Enabled = selCell;
+ nudY.Enabled = selCell;
+ nudZ.Enabled = selCell;
+ nudSize.Enabled = selCell;
+ pColor.Enabled = selCell;
+ cbType.Enabled = false;
+ }
+
+ private void Reset3D()
+ {
+
+ if (SelectedCreature == null)
+ mini = new Mini3D();
+ else
+ mini = SelectedCreature.Get3D();
+ pRender.Invalidate();
+ }
+
+ private void CommitChanges()
+ {
+ if (SelectedCell != null)
+ lbCells.Items[lbCells.SelectedIndex] = SelectedCell;
+ if (SelectedCreature != null)
+ lbCreatures.Items[lbCreatures.SelectedIndex] = SelectedCreature;
+ Reset3D();
+ }
+
+ private Creature SelectedCreature => lbCreatures.SelectedItem as Creature;
+ private CreatureCell SelectedCell => lbCells.SelectedItem as CreatureCell;
+
+ private void pRender_Paint(object sender, PaintEventArgs e)
+ {
+ // Init and draw ball boundaries
+ e.Graphics.Clear(Color.DarkOrchid);
+ e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
+ e.Graphics.TranslateTransform(10, 10);
+ e.Graphics.ScaleTransform(4, 4);
+ e.Graphics.DrawEllipse(ballPen, new Rectangle(0, 0, 64, 64));
+ e.Graphics.DrawEllipse(ballPen, new RectangleF(31.5f, 31.5F, 1, 1));
+ e.Graphics.TranslateTransform(32, 32);
+ if (mini != null)
+ {
+ mini.Rotation = rotation;
+ mini.Draw(e.Graphics);
+ }
+ }
+
+ private void btCreatureAdd_Click(object sender, System.EventArgs e)
+ {
+ Creature c = new Creature();
+ lbCreatures.SelectedIndex = lbCreatures.Items.Add(c);
+ }
+
+ private void lbCreatures_SelectedValueChanged(object sender, System.EventArgs e)
+ {
+ if (loading || SelectedCreature == null)
+ return;
+ loading = true;
+ try
+ {
+ tbCName.Text = SelectedCreature.Name;
+ lbCells.Items.Clear();
+ lbCells.Items.AddRange(SelectedCreature.Cells.ToArray());
+ }
+ finally
+ {
+ loading = false;
+ }
+ if (lbCells.Items.Count > 0)
+ lbCells.SelectedIndex = 0;
+ else
+ UIStatus();
+ Reset3D();
+ }
+
+ private void tbCName_TextChanged(object sender, System.EventArgs e)
+ {
+ if (loading || SelectedCreature == null)
+ return;
+ SelectedCreature.Name = tbCName.Text;
+ lbCreatures.Items[lbCreatures.SelectedIndex] = SelectedCreature;
+ }
+
+ private void btCreatureRemove_Click(object sender, System.EventArgs e)
+ {
+ if (SelectedCreature == null)
+ return;
+ int idx = lbCreatures.SelectedIndex;
+ lbCreatures.Items.RemoveAt(idx);
+ if (lbCreatures.Items.Count > 0)
+ lbCreatures.SelectedIndex = lbCreatures.Items.Count > idx ? idx : lbCreatures.Items.Count - 1;
+ else
+ {
+ loading = true;
+ try
+ {
+ tbCName.Text = "";
+ nudX.Value = nudY.Value = nudZ.Value = 0;
+ pColor.BackColor = SystemColors.ButtonFace;
+ cbType.SelectedValue = null;
+ lbCells.Items.Clear();
+ }
+ finally
+ {
+ loading = false;
+ }
+ UIStatus();
+ Reset3D();
+ }
+ }
+
+ private void btCellAdd_Click(object sender, System.EventArgs e)
+ {
+ if (loading || SelectedCreature == null)
+ return;
+ int idx = -1;
+ loading = true;
+ try
+ {
+ CreatureCell cc = new CreatureCell();
+ SelectedCreature.Cells.Add(cc);
+ idx = lbCells.Items.Add(cc);
+ CommitChanges();
+ }
+ finally { loading = false; }
+ lbCells.SelectedIndex = idx;
+ }
+
+ private void lbCells_SelectedValueChanged(object sender, System.EventArgs e)
+ {
+ if (loading || SelectedCreature == null || SelectedCell == null)
+ return;
+ loading = true;
+ try
+ {
+ nudX.Value = (decimal)SelectedCell.Position.X;
+ nudY.Value = (decimal)SelectedCell.Position.Y;
+ nudZ.Value = (decimal)SelectedCell.Position.Z;
+ nudSize.Value = (decimal)SelectedCell.Size;
+ pColor.BackColor = SelectedCell.Color;
+ cbType.SelectedValue = SelectedCell.CellType;
+ }
+ finally { loading = false; }
+ UIStatus();
+ Reset3D();
+ }
+
+ private void btCellRemove_Click(object sender, System.EventArgs e)
+ {
+ if (SelectedCreature == null || SelectedCell == null)
+ return;
+ int idx = lbCells.SelectedIndex;
+ SelectedCreature.Cells.RemoveAt(idx); // Same index (synched list)
+ lbCells.Items.RemoveAt(idx);
+ if (lbCells.Items.Count > 0)
+ lbCells.SelectedIndex = lbCells.Items.Count > idx ? idx : lbCells.Items.Count - 1;
+ else
+ {
+ loading = true;
+ try
+ {
+ nudX.Value = nudY.Value = nudZ.Value = 0;
+ pColor.BackColor = SystemColors.ButtonFace;
+ cbType.SelectedValue = null;
+ }
+ finally
+ {
+ loading = false;
+ }
+ UIStatus();
+ }
+ CommitChanges();
+ }
+
+ private void PositionChanged(object sender, System.EventArgs e)
+ {
+ if (loading || SelectedCreature == null || SelectedCell == null)
+ return;
+ loading = true;
+ try
+ {
+ SelectedCell.Position = new Vector3((float)nudX.Value, (float)nudY.Value, (float)nudZ.Value);
+ SelectedCell.Size = (float)nudSize.Value;
+ CommitChanges();
+ }
+ finally
+ {
+ loading = false;
+ }
+ }
+
+ private void btReset_Click(object sender, System.EventArgs e)
+ {
+ rotation = new Vector3();
+ Reset3D();
+ }
+
+ private void pRender_MouseDown(object sender, MouseEventArgs e)
+ {
+ rotating = true;
+ mousePos = e.Location;
+ }
+
+ private void pRender_MouseUp(object sender, MouseEventArgs e)
+ {
+ rotating = false;
+ }
+
+ private void pRender_MouseLeave(object sender, System.EventArgs e)
+ {
+ rotating = false;
+ }
+
+ private void pRender_MouseMove(object sender, MouseEventArgs e)
+ {
+ if (!rotating)
+ return;
+ rotation.X += (e.Y - mousePos.Y) / 30f;
+ rotation.Y += (e.X - mousePos.X) / 30f;
+ mousePos = e.Location;
+ pRender.Invalidate();
+ }
+
+ private void pColor_Click(object sender, System.EventArgs e)
+ {
+ if (loading || SelectedCreature == null || SelectedCell == null)
+ return;
+ colorPicker.Color = SelectedCell.Color;
+ if (colorPicker.ShowDialog() == DialogResult.OK)
+ {
+ SelectedCell.Color = colorPicker.Color;
+ pColor.BackColor = colorPicker.Color;
+ CommitChanges();
+ }
+ }
+
+ private void CreatureEditor_FormClosed(object sender, FormClosedEventArgs e)
+ {
+ colorPicker.Dispose();
+ }
+
+ private void copyCreatureToolStripMenuItem_Click(object sender, System.EventArgs e)
+ {
+ if (SelectedCreature == null)
+ return;
+ Clipboard.SetText(SelectedCreature.Serialize());
+ }
+
+ private void pasteCreatureToolStripMenuItem_Click(object sender, System.EventArgs e)
+ {
+ if (SelectedCreature == null)
+ return;
+ string cdata = Clipboard.GetText();
+ SelectedCreature.Deserialize(cdata);
+ CommitChanges();
+ }
+
+ private void pasteCreatureAsNewToolStripMenuItem_Click(object sender, System.EventArgs e)
+ {
+ btCreatureAdd_Click(sender, e);
+ SelectedCreature.Name = "Error";
+ pasteCreatureToolStripMenuItem_Click(sender, e);
+ }
+
+ private void bounceToolStripMenuItem_Click(object sender, System.EventArgs e)
+ {
+ MainForm.MakeGola(SelectedCreature);
+ }
+ }
+}
diff --git a/Gola2/CreatureEditor.resx b/Gola2/CreatureEditor.resx
new file mode 100644
index 0000000..bb52121
--- /dev/null
+++ b/Gola2/CreatureEditor.resx
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/Gola2/Creatures.cs b/Gola2/Creatures.cs
new file mode 100644
index 0000000..da6f44d
--- /dev/null
+++ b/Gola2/Creatures.cs
@@ -0,0 +1,197 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Text;
+
+namespace Gola2
+{
+ static class CreatureDB
+ {
+ static CreatureDB()
+ {
+ Load();
+ }
+
+ private static void Load()
+ {
+ string[] crs=Properties.Resources.Creatures.Split('\n');
+ foreach(string cr in crs)
+ {
+ string cc = cr.Trim();
+ if (cc.Length == 0)
+ continue;
+ Creature c = new Creature();
+ c.Deserialize(cc);
+ if (c.Cells.Count > 0)
+ Creatures.Add(c);
+ }
+ }
+
+ private static void Save()
+ {
+
+ }
+
+ public static List Creatures { get; } = new List();
+ }
+
+ public enum CreatureCellType
+ {
+ Normal,
+ Fur,
+ Eye
+ }
+
+ public class CreatureCell
+ {
+ public override string ToString()
+ {
+ return "Cell size:" + Size.ToString("0.00") + " color:" + GetColorCode();
+ }
+
+ public string GetColorCode()
+ {
+ return Color.Name;
+ }
+
+ public Vector3 Position { get; set; }
+ public Color Color { get; set; } = Color.White;
+ public float Size { get; set; } = 5f;
+ public CreatureCellType CellType { get; set; }
+ }
+
+ public class Creature
+ {
+ #region RandomName
+ private const string NAME_PART_C = "bcdfghklnmnpqrstvwz";
+ private const string NAME_PART_V = "aeiou";
+
+ private static Random rnd = new Random();
+ public static string RandomName()
+ {
+ StringBuilder sb = new StringBuilder();
+ int names = rnd.Next(1, 3);
+ for (int i = 0; i < names; i++)
+ {
+ int times = rnd.Next(2, 5);
+ bool upper = true;
+ if (sb.Length > 0)
+ sb.Append(" '"[rnd.Next(2)]);
+ for (int j = 0; j < times; j++)
+ {
+ char c = NAME_PART_C[rnd.Next(NAME_PART_C.Length)];
+ char v = NAME_PART_V[rnd.Next(NAME_PART_V.Length)];
+ if (upper)
+ {
+ c = char.ToUpper(c);
+ upper = false;
+ }
+ sb.Append(c);
+ sb.Append(v);
+ }
+ }
+ return sb.ToString();
+ }
+ #endregion
+
+ #region Serialization Tools
+
+ private static string SColor(Color c)
+ {
+ return c.ToArgb().ToString("X");
+ }
+
+ private static Color DColor(string s)
+ {
+ int argb = int.Parse(s, System.Globalization.NumberStyles.HexNumber);
+ return Color.FromArgb(argb);
+ }
+
+ #endregion
+
+ public Creature()
+ {
+ Name = RandomName();
+ }
+
+ public string Serialize()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append(0);
+ sb.Append(';');
+ sb.Append(Name.Replace(";", ""));
+ foreach (CreatureCell c in Cells)
+ {
+ sb.Append(';');
+ sb.Append((int)c.CellType);
+ sb.Append(';');
+ sb.Append(c.Position.X);
+ sb.Append(';');
+ sb.Append(c.Position.Y);
+ sb.Append(';');
+ sb.Append(c.Position.Z);
+ sb.Append(';');
+ sb.Append(c.Size);
+ sb.Append(';');
+ sb.Append(SColor(c.Color));
+ }
+ return sb.ToString();
+ }
+
+ public void Deserialize(string data)
+ {
+ Cells.Clear();
+ string[] dt = data.Split(';');
+ try
+ {
+ switch (int.Parse(dt[0]))
+ {
+ case 0:
+ Deserialize0(dt);
+ break;
+ default:
+ throw new NotImplementedException("Unknown format version");
+ }
+ }
+ catch (FormatException) { }
+ }
+
+ private void Deserialize0(string[] dt)
+ {
+ try
+ {
+ Name = dt[1];
+ for (int i = 2; i < dt.Length;)
+ {
+ Vector3 pos = new Vector3();
+ CreatureCell c = new CreatureCell();
+ Cells.Add(c);
+ c.CellType = (CreatureCellType)int.Parse(dt[i++]);
+ pos.X = float.Parse(dt[i++]);
+ pos.Y = float.Parse(dt[i++]);
+ pos.Z = float.Parse(dt[i++]);
+ c.Position = pos;
+ c.Size = float.Parse(dt[i++]);
+ c.Color = DColor(dt[i++]);
+ }
+ }
+ catch { }
+ }
+
+ public Mini3D Get3D()
+ {
+ Mini3D mini = new Mini3D();
+ foreach (CreatureCell cell in Cells)
+ mini.Add(cell.Position.X, cell.Position.Y, cell.Position.Z, cell.Color, cell.Size, cell);
+ return mini;
+ }
+
+ public override string ToString()
+ {
+ return Name + " (" + Cells.Count + ")";
+ }
+
+ public string Name { get; set; }
+ public List Cells { get; } = new List();
+ }
+}
diff --git a/Gola2/Gola.cs b/Gola2/Gola.cs
index 18ce218..c553b71 100644
--- a/Gola2/Gola.cs
+++ b/Gola2/Gola.cs
@@ -12,17 +12,30 @@
private int radious = 32;
private Color color;
private Brush fillBrush;
+ private Brush fillBrushBack;
private RectangleF fillRectangle;
+ private Vector3 rotation;
+ private Vector3 rforce;
+ private Mini3D content;
- public Gola()
+ public Gola(Creature creature)
{
Sprite = Properties.Resources.Ball2;
Position = new PointF(rndf(ScreenLeft, ScreenRight), ScreenBottom);
- force.Y = -rndf(40);
- force.X = rndf(-20, 20);
- color = Color.FromArgb(rnd(0, 255), rnd(0, 255), rnd(0, 255));
- fillBrush = new SolidBrush(Color.FromArgb(rnd(40, 70), color));
+ force.Y = -rndf(40) / 100;
+ force.X = rndf(-20, 20) / 100;
+ do
+ {
+ color = Color.FromArgb(rnd(0, 255), rnd(0, 255), rnd(0, 255));
+ } while (color.A + color.G + color.B > 200 && color.A + color.G + color.B < 400);
+ fillBrush = new SolidBrush(Color.FromArgb(rnd(70, 200), color));
+ fillBrushBack = new SolidBrush(Color.FromArgb(150, 255, 255, 255));
fillRectangle = new RectangleF(-radious, -radious, radious * 2, radious * 2);
+ rforce = Vector3.Random() * 0.05f;
+ rotation = Vector3.Random() * 360;
+ // == CONTENT
+ if (creature != null)
+ content = creature.Get3D();
}
protected internal override void Start()
@@ -33,6 +46,7 @@
{
Position = new PointF(Position.X + force.X, Position.Y + force.Y);
force.Y += GRAV;
+ rotation += rforce;
CheckBounds();
CheckCollision();
}
@@ -40,11 +54,20 @@
protected internal override void Render(Graphics g)
{
RenderTransform(g);
- g.FillEllipse(fillBrush, fillRectangle);
+ g.FillEllipse(fillBrushBack, fillRectangle);
+ RenderContent(g);
g.FillEllipse(fillBrush, fillRectangle);
RenderSprite(g);
}
+ private void RenderContent(Graphics g)
+ {
+ if (content == null)
+ return;
+ content.Rotation = rotation;
+ content.Draw(g);
+ }
+
private void CheckBounds()
{
if (Y > ScreenBottom)
diff --git a/Gola2/Gola2.csproj b/Gola2/Gola2.csproj
index 26a659a..bd5c8fe 100644
--- a/Gola2/Gola2.csproj
+++ b/Gola2/Gola2.csproj
@@ -46,6 +46,13 @@
+
+ Form
+
+
+ CreatureEditor.cs
+
+
Form
@@ -57,8 +64,15 @@
MainForm.cs
+
+
+ Component
+
+
+ CreatureEditor.cs
+
MainForm.cs
@@ -83,16 +97,11 @@
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/Gola2/Gola2.csproj.user b/Gola2/Gola2.csproj.user
new file mode 100644
index 0000000..94c0561
--- /dev/null
+++ b/Gola2/Gola2.csproj.user
@@ -0,0 +1,6 @@
+
+
+
+ editor
+
+
\ No newline at end of file
diff --git a/Gola2/MainForm.Designer.cs b/Gola2/MainForm.Designer.cs
index 2d15846..e533139 100644
--- a/Gola2/MainForm.Designer.cs
+++ b/Gola2/MainForm.Designer.cs
@@ -32,15 +32,16 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.notifyIcon = new System.Windows.Forms.NotifyIcon(this.components);
this.trayMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
- this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.addGolaToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.removeGolaToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
+ this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
+ this.editorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.trayMenuStrip.SuspendLayout();
this.SuspendLayout();
//
@@ -59,23 +60,12 @@
this.addGolaToolStripMenuItem,
this.removeGolaToolStripMenuItem,
this.toolStripSeparator2,
+ this.editorToolStripMenuItem,
this.aboutToolStripMenuItem,
this.toolStripSeparator1,
this.exitToolStripMenuItem});
this.trayMenuStrip.Name = "trayMenuStrip";
- this.trayMenuStrip.Size = new System.Drawing.Size(181, 126);
- //
- // exitToolStripMenuItem
- //
- this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
- this.exitToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
- this.exitToolStripMenuItem.Text = "Exit";
- this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
- //
- // toolStripSeparator1
- //
- this.toolStripSeparator1.Name = "toolStripSeparator1";
- this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6);
+ this.trayMenuStrip.Size = new System.Drawing.Size(181, 148);
//
// addGolaToolStripMenuItem
//
@@ -103,6 +93,18 @@
this.aboutToolStripMenuItem.Text = "About";
this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
//
+ // toolStripSeparator1
+ //
+ this.toolStripSeparator1.Name = "toolStripSeparator1";
+ this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6);
+ //
+ // exitToolStripMenuItem
+ //
+ this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
+ this.exitToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.exitToolStripMenuItem.Text = "Exit";
+ this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
+ //
// label1
//
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
@@ -131,6 +133,13 @@
this.label3.Text = "USE WITH CAUTION!";
this.label3.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
//
+ // editorToolStripMenuItem
+ //
+ this.editorToolStripMenuItem.Name = "editorToolStripMenuItem";
+ this.editorToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.editorToolStripMenuItem.Text = "Editor";
+ this.editorToolStripMenuItem.Click += new System.EventHandler(this.editorToolStripMenuItem_Click);
+ //
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -162,5 +171,6 @@
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.ToolStripMenuItem editorToolStripMenuItem;
}
}
\ No newline at end of file
diff --git a/Gola2/MainForm.cs b/Gola2/MainForm.cs
index 07b8b9c..4c698b6 100644
--- a/Gola2/MainForm.cs
+++ b/Gola2/MainForm.cs
@@ -1,10 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
using System.Windows.Forms;
using XWolf;
@@ -12,21 +6,32 @@
{
public partial class MainForm : Form
{
+ private static MainForm INSTANCE;
+
public MainForm()
{
+ INSTANCE = this;
InitializeComponent();
- CSDiv.Start();
- CreateGola();
+ //CreateGola();
}
- public void CreateGola()
+ public void CreateGola(Creature creature = null )
{
- new Gola();
+ if (!CSDiv.Active)
+ CSDiv.Start();
+ new Gola(creature);
+ }
+
+ public static void MakeGola(Creature creature)
+ {
+ if (INSTANCE==null)
+ new MainForm();
+ INSTANCE.CreateGola(creature);
}
public void DestroyGola()
{
-
+ //acces and kill!!
}
private void notifyIcon_DoubleClick(object sender, EventArgs e)
@@ -73,5 +78,10 @@
{
Show();
}
+
+ private void editorToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ CreatureEditor.Execute();
+ }
}
}
diff --git a/Gola2/Mini3D.cs b/Gola2/Mini3D.cs
new file mode 100644
index 0000000..fc7ce79
--- /dev/null
+++ b/Gola2/Mini3D.cs
@@ -0,0 +1,196 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+
+namespace Gola2
+{
+ public struct Vector3
+ {
+ private static string FORMAT = "+0000.00;-0000.00; 0000.00";
+ public float X;
+ public float Y;
+ public float Z;
+
+ public Vector3(float x, float y, float z)
+ {
+ X = x;
+ Y = y;
+ Z = z;
+ }
+
+ public static Vector3 Random()
+ {
+ return new Vector3(Mini3D.rndf(), Mini3D.rndf(), Mini3D.rndf());
+ }
+
+ public static Vector3 operator +(Vector3 v1, Vector3 v2)
+ {
+ return new Vector3(v1.X + v2.X, v1.Y + v2.Y, v1.Z + v2.Z);
+ }
+ public static Vector3 operator -(Vector3 v1, Vector3 v2)
+ {
+ return new Vector3(v1.X - v2.X, v1.Y - v2.Y, v1.Z - v2.Z);
+ }
+ public static Vector3 operator -(Vector3 v)
+ {
+ return new Vector3(-v.X, -v.Y, -v.Z);
+ }
+ public static Vector3 operator *(Vector3 v1, Vector3 v2)
+ {
+ return new Vector3(v1.X * v2.X, v1.Y * v2.Y, v1.Z * v2.Z);
+ }
+ public static Vector3 operator /(Vector3 v1, Vector3 v2)
+ {
+ return new Vector3(v1.X / v2.X, v1.Y / v2.Y, v1.Z / v2.Z);
+ }
+ public static Vector3 operator *(Vector3 v, float f)
+ {
+ return new Vector3(v.X * f, v.Y * f, v.Z * f);
+ }
+ public static Vector3 operator /(Vector3 v, float f)
+ {
+ return new Vector3(v.X / f, v.Y / f, v.Z / f);
+ }
+
+ public override string ToString()
+ {
+ return "X:" + X.ToString(FORMAT) +" Y:" + Y.ToString(FORMAT) + " Z:" + Z.ToString(FORMAT);
+ }
+
+ public float Magnitude => (float)Math.Sqrt(X * X + Y * Y + Z * Z);
+
+ public Vector3 Normalized
+ {
+ get
+ {
+ float m = Magnitude;
+ if (m > 0)
+ return new Vector3(X / m, Y / m, Z / m);
+ return new Vector3(0, 0, 0);
+ }
+ }
+
+ }
+
+ public class Mini3D
+ {
+ #region Static
+
+ public static Random Random { get; } = new Random();
+
+ public static int rnd(int min, int max)
+ {
+ return Random.Next(min, max);
+ }
+
+ public static float rndf()
+ {
+ return (float)Random.NextDouble();
+ }
+
+ public static float rndf(float max)
+ {
+ return rndf() * max;
+ }
+
+ public static float rndf(float min, float max)
+ {
+ return min + rndf(max - min);
+ }
+
+ #endregion
+
+ protected struct Cell
+ {
+ public Vector3 Position;
+ public Color Color;
+ public float Size;
+ public object Info;
+
+ public override string ToString()
+ {
+ return "(" + Position.ToString() + ") Size:" + Size.ToString("0.##") + " " + Color.Name + (Info == null ? "" : " [INFO]");
+ }
+ }
+
+ private List cells = new List();
+
+ public Mini3D()
+ {
+ }
+
+ public void Add(float x, float y, float z, Color c)
+ {
+ Add(x, y, z, c, 1, null);
+ }
+
+ public void Add(float x, float y, float z, Color c, float size, object info)
+ {
+ cells.Add(new Cell() { Position = new Vector3(x, y, z), Color = c, Size = size, Info = info });
+ }
+
+ public void Draw(Graphics g)
+ {
+ float fd = FocalDistance;
+ Vector3 angle = Rotation;
+ float sinZ = (float)Math.Sin(angle.Z);
+ float cosZ = (float)Math.Cos(angle.Z);
+ float sinY = (float)Math.Sin(angle.Y);
+ float cosY = (float)Math.Cos(angle.Y);
+ float sinX = (float)Math.Sin(angle.X);
+ float cosX = (float)Math.Cos(angle.X);
+
+ List pcells = new List| ();
+
+ foreach (Cell c in cells)
+ {
+ Vector3 pos = c.Position;
+ float x = pos.X, y = pos.Y, z = pos.Z, xx, yy;
+ //Rotation
+ // Z
+ xx = x * cosZ - y * sinZ;
+ y = y * cosZ + x * sinZ;
+ x = xx;
+ // Y
+ xx = x * cosY - z * sinY;
+ z = z * cosY + x * sinY;
+ x = xx;
+ // X
+ yy = y * cosX - z * sinX;
+ z = z * cosX + y * sinX;
+ y = yy;
+ ////Projection
+ //z += 500;
+ //if (z > 0.1)
+ //{
+ // x = x * fd / z;
+ // y = y * fd / z;
+ //}
+ //else
+ //{
+ // continue;
+ //}
+ pcells.Add(new Cell() { Position = new Vector3(x, y, z), Color = c.Color, Size = c.Size, Info = c.Info });
+ }
+
+ pcells.Sort((Cell a, Cell b) => (a.Position.Z > b.Position.Z) ? -1 : 1);
+ DrawCells(g, pcells.ToArray());
+ }
+
+ protected virtual void DrawCells(Graphics g, Cell[] cells)
+ {
+ foreach (Cell c in cells)
+ {
+ using (Brush b = new SolidBrush(c.Color))
+ {
+ float s2 = c.Size / 2;
+ g.FillEllipse(b, new RectangleF(c.Position.X - s2, c.Position.Y - s2, c.Size, c.Size));
+ }
+ }
+ }
+
+ public Vector3 Rotation { get; set; }
+ public float Zoom { get; set; } = 1;
+ public float FocalDistance { get; set; } = 500;
+ }
+}
diff --git a/Gola2/PanelDBuf.cs b/Gola2/PanelDBuf.cs
new file mode 100644
index 0000000..5694282
--- /dev/null
+++ b/Gola2/PanelDBuf.cs
@@ -0,0 +1,19 @@
+using System.Windows.Forms;
+
+namespace Gola2
+{
+ class PanelDBuf : Panel
+ {
+ public PanelDBuf()
+ {
+ DoubleBuffered = true;
+
+ //// or
+
+ //SetStyle(ControlStyles.AllPaintingInWmPaint, true);
+ //SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
+ //UpdateStyles();
+ }
+ }
+
+}
diff --git a/Gola2/Program.cs b/Gola2/Program.cs
index bf2b482..386255e 100644
--- a/Gola2/Program.cs
+++ b/Gola2/Program.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Windows.Forms;
namespace Gola2
@@ -16,8 +14,24 @@
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
- main = new MainForm();
- Application.Run();
+ if (CheckArguments())
+ {
+ main = new MainForm();
+ Application.Run();
+ }
+ }
+
+ static bool CheckArguments()
+ {
+ string[] args = Environment.GetCommandLineArgs();
+ if (args.Length < 2)
+ return true;
+ if (args[1].ToLower() == "editor")
+ {
+ CreatureEditor.Execute();
+ return false;
+ }
+ return true;
}
}
}
diff --git a/Gola2/Properties/Resources.Designer.cs b/Gola2/Properties/Resources.Designer.cs
index bb0e325..9ee7026 100644
--- a/Gola2/Properties/Resources.Designer.cs
+++ b/Gola2/Properties/Resources.Designer.cs
@@ -69,5 +69,14 @@
return ((System.Drawing.Bitmap)(obj));
}
}
+
+ ///
+ /// Looks up a localized string similar to 0;Ozo;0;0;-4;0;10;FFD09A5E;0;0;5;0;14;FFD09A5E;0;-3;-4;-2,5;2;FF000000;0;3;-4;-2,5;2;FF000000;0;-5;-8;1;5;FFD09A5E;0;5;-8;1;5;FFD09A5E;0;-4,5;-8;0;3;FFE4C7A5;0;4,5;-8;0;3;FFE4C7A5;0;0;-3;-3;3;FFE4C7A5;0;4;2;-5;4;FFE4C7A5;0;-4;2;-5;4;FFE4C7A5;0;-4;10;-5;5;FFE4C7A5;0;4;10;-5;5;FFE4C7A5;0;0;7;7;5;FFE4C7A5.
+ ///
+ internal static string Creatures {
+ get {
+ return ResourceManager.GetString("Creatures", resourceCulture);
+ }
+ }
}
}
diff --git a/Gola2/Properties/Resources.resx b/Gola2/Properties/Resources.resx
index 2f941fe..8d8de43 100644
--- a/Gola2/Properties/Resources.resx
+++ b/Gola2/Properties/Resources.resx
@@ -121,4 +121,7 @@
..\Resources\Ball2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\Resources\Creatures.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252
+
\ No newline at end of file
diff --git a/Gola2/Resources/Creatures.txt b/Gola2/Resources/Creatures.txt
new file mode 100644
index 0000000..2ca9510
--- /dev/null
+++ b/Gola2/Resources/Creatures.txt
@@ -0,0 +1,2 @@
+0;Ozo;0;0;-4;0;10;FFD09A5E;0;0;5;0;14;FFD09A5E;0;-3;-4;-2,5;2;FF000000;0;3;-4;-2,5;2;FF000000;0;-5;-8;1;5;FFD09A5E;0;5;-8;1;5;FFD09A5E;0;-4,5;-8;0;3;FFE4C7A5;0;4,5;-8;0;3;FFE4C7A5;0;0;-3;-3;3;FFE4C7A5;0;4;2;-5;4;FFE4C7A5;0;-4;2;-5;4;FFE4C7A5;0;-4;10;-5;5;FFE4C7A5;0;4;10;-5;5;FFE4C7A5;0;0;7;7;5;FFE4C7A5
+0;Rimolesi;0;0;0;0;20;FFFFFFFF;0;-10;-7;0;12;FFFFFFFF;0;-13;-7;0;9;FFFFFFFF;0;-18;-7;0;4;FF000000
| | | |