Skip to content

Commit

Permalink
Merge pull request #20 from spiiin/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
spiiin authored Jan 30, 2019
2 parents afc6161 + 8cc9009 commit b0c2c29
Show file tree
Hide file tree
Showing 74 changed files with 808 additions and 183 deletions.
3 changes: 3 additions & 0 deletions CadEditor/ConfigScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ namespace CadEditor

public delegate void DrawObjectFunc(Graphics g, ObjectRec curObject, int listNo, bool selected, float curScale, ImageList objectSprites, bool inactive, int leftMargin, int topMargin);
public delegate void DrawObjectBigFunc(Graphics g, ObjectRec curObject, int listNo, bool selected, float curScale, Image[] objectSprites, bool inactive, int leftMargin, int topMargin);
public delegate bool SelectObjectBigFunc(ObjectRec objRec, Image[] objectSprites, int x, int y);

public delegate Screen[] LoadScreensFunc();
public delegate void SaveScreensFunc(Screen[] screens);
Expand Down Expand Up @@ -269,6 +270,7 @@ public static void LoadFromFile(string fileName)

drawObjectFunc = callFromScript<DrawObjectFunc>(asm, data, "*.getDrawObjectFunc");
drawObjectBigFunc = callFromScript<DrawObjectBigFunc>(asm, data, "*.getDrawObjectBigFunc");
selectObjectBigFunc = callFromScript<SelectObjectBigFunc>(asm, data, "*.getSelectObjectBigFunc");

renderToMainScreenFunc = callFromScript<RenderToMainScreenFunc>(asm, data, "*.getRenderToMainScreenFunc");

Expand Down Expand Up @@ -829,6 +831,7 @@ public static byte[] getScrollByteArray()

public static DrawObjectFunc drawObjectFunc;
public static DrawObjectBigFunc drawObjectBigFunc;
public static SelectObjectBigFunc selectObjectBigFunc;

public static LoadScreensFunc loadScreensFunc;
public static SaveScreensFunc saveScreensFunc;
Expand Down
10 changes: 6 additions & 4 deletions CadEditor/EnemyEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,9 @@ private void mapScreen_MouseDown(object sender, MouseEventArgs e)
var obj = activeObjectList.objects[i];
if ((obj.sx == sx) && (obj.sy == sy))
{
if (isMouseInside(obj, x, y, objectSpritesBig))
var selectObjectBigFunc = ConfigScript.selectObjectBigFunc;
bool selected = selectObjectBigFunc?.Invoke(obj, objectSpritesBig, x, y) ?? isMouseInside(obj, x, y, objectSpritesBig);
if (selected)
{
dgvObjects.Rows[i].Selected = !dgvObjects.Rows[i].Selected;
}
Expand Down Expand Up @@ -831,7 +833,6 @@ private void mapScreen_MouseClick(object sender, MouseEventArgs e)
var activeObjectList = objectLists[curActiveObjectListIndex];
activeObjectList.objects.Insert(insertPos, obj);

dgvObjects.DataSource = null;
fillObjectsDataGrid();
}
else if (curTool == ToolType.Delete)
Expand Down Expand Up @@ -898,7 +899,7 @@ private void cbObjectList_SelectedIndexChanged(object sender, EventArgs e)

private void dgvObjects_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e.ColumnIndex == 1)
if (e.ColumnIndex == 0)
{
var row = dgvObjects.Rows[e.RowIndex];
int cell0 = Convert.ToInt32(row.Cells[1].Value);
Expand All @@ -908,7 +909,8 @@ private void dgvObjects_CellFormatting(object sender, DataGridViewCellFormatting
//update icon
if ((cell0 >= 0) && (cell0 < objectSprites.Images.Count))
{
row.Cells[0].Value = objectSprites.Images[cell0];
e.Value = objectSprites.Images[cell0];
e.FormattingApplied = true;
}

//update dictionary
Expand Down
94 changes: 43 additions & 51 deletions CadEditor/FormMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b0c2c29

Please sign in to comment.