⚠ Cookies ⚠

By continuing to use this site you agree to the use of cookies. Please visit this page to see exactly how we use these.

Projects

AGS EditorRoom EditorPoint plotting in the Room Editor
Joseph DiPerla[quote]
*Point plotting for walkable area's, regions and hotspots. - Basically clicking a point on the screen at one location, then another and the editor would draw a line from that point to the next and continue doing so until the last point connects to the first and there you have your hotspot/region/walkable area, etc...
[/quote]

I know we have a line tool, but at times I miss connecting the line properly. Plus this eliminates the holding down of the mouse button while drawing these area's, making it significantly easier and faster to get done.
Joseph DiPerlaJust so you have an idea of what the heck I am talking about, look over here: http://www.youtube.com/watch?v=_YML2b52Kuo&feature=relmfu  and look around the 2:50 to 3:20 mark to see what I am talking about.
Joseph DiPerlaSo I found this here: http://msdn.microsoft.com/en-us/library/f956fzw1.aspx

Perhaps using this code:


public void DrawLinePoint(PaintEventArgs e)
{

    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);

    // Create points that define line.
    Point point1 = new Point(100, 100);
    Point point2 = new Point(500, 100);

    // Draw line to screen.
    e.Graphics.DrawLine(blackPen, point1, point2);
}


Only under a Do While which will wait for the escape key to be pressed. So it would work something like:

After the line was drawn, you can copy the point2 coordinates to point1, then start a new  point2 location and do the drawline until the user presses esc. I dont know.. C# is not my strong point.
Joseph DiPerlaThis might work better: http://msdn.microsoft.com/en-us/library/7ewkcdb3.aspx
Crimson Wizard[quote author=Joseph DiPerla link=issue=304.com429#com429 date=1343141612]
Only under a Do While which will wait for the escape key to be pressed. So it would work something like:
After the line was drawn, you can copy the point2 coordinates to point1, then start a new  point2 location and do the drawline until the user presses esc. I dont know.. C# is not my strong point.
[/quote]
That has nothing to do with C#, it's making an algorythm that matters at this point. That would be the same for C++, Java or anything else even little similar.
Making this in do/while will block program execution unless you do it in a separate thread... which would be impossible since you are referencing GUI created on the main thread.
EDIT: but wait, I remembered there's such thing as Invoke / InvokeRequired. My mistake ;) still...

There should be terribly simple solution for this based on event handling without any loops in the code.
I may think of the following: you put the program in "drawing mode" by setting some var. If a click or keypress occurs you check the program mode. If it is your mode, then process the action by adding new point/cancelling or whatever. Meanwhile you paint an array of lines. Also draw extra line from the last point to the cursor position to make user see he is still drawing.

I am saying all this without having much knowledge about how Editor works. Perhaps there's already some "mode" variable (maybe not one).
Joseph DiPerlaThe thing is, why, if I am in the process of drawing a hotspot/walkbehind/region/walkable area, would I need the rest of the program to be running, especially while point plotting? Once you are done with the plotting, you just press escape and the app will run as normal.

Technically, I would think something like this should work just fine, I just do not know where to implement it in the editor or how to do it correctly:

public void DrawLinesPointF(PaintEventArgs e)
{

Pen pen = new Pen(Color.Black, 3);
PointF[] points =
{
do
{
new PointF( pointx,  point.y),    
} while (!key.return)
};
//Draw lines to screen.
e.Graphics.DrawLines(pen, points);
}

I have no idea how that looks, but I tried anyway...
Crimson Wizard[quote author=Joseph DiPerla link=issue=304.com432#com432 date=1343188011]
The thing is, why, if I am in the process of drawing a hotspot/walkbehind/region/walkable area, would I need the rest of the program to be running, especially while point plotting? Once you are done with the plotting, you just press escape and the app will run as normal. [/quote]
No, it won't work like that. To get a key press you must receive events, and to receive events you must pass the execution to main program loop once in a while. That is - exit the drawing function. I remember you mentioned you program in VB. Does not Visual Basic work the same?

[quote author=Joseph DiPerla link=issue=304.com432#com432 date=1343188011]
Technically, I would think something like this should work just fine, I just do not know where to implement it in the editor or how to do it correctly:

public void DrawLinesPointF(PaintEventArgs e)
{

Pen pen = new Pen(Color.Black, 3);
PointF[] points =
{
do
{
new PointF( pointx,  point.y),    
} while (!key.return)
};
//Draw lines to screen.
e.Graphics.DrawLines(pen, points);
}

I have no idea how that looks, but I tried anyway...
[/quote]
That  looks weird :P.
Firstly the thing abour key press I mentioned. Secondly... your array initialization looks so... uncommon :). You can't do it like that. You can't put any statement inside array initialization block except for creating new object (new PointF) or a call to another function (like GetPoint()).
I doubt that code will even compile.
© Adventure Game Studio 2024. Page design by loominous and Darth Mandarb; coding by AGA.
Page generated on 06 May 2024 at 18:00:50