3 registered members (VoroneTZ, monk12, Quad),
829
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: C# wrapper - A7.80 V1.0.2
[Re: Stromausfall]
#285903
08/21/09 11:33
08/21/09 11:33
|
Joined: Aug 2005
Posts: 1,230
MichaelGale
Serious User
|
Serious User
Joined: Aug 2005
Posts: 1,230
|
I was going to point that out, but pointers are valid in C# in an unsafe context if you compile the assembly with the /unsafe switch. See here.
Your friendly mod is at your service.
|
|
|
Re: C# wrapper - A7.80 V1.0.2
[Re: MichaelGale]
#285907
08/21/09 14:03
08/21/09 14:03
|
Joined: Nov 2007
Posts: 1,143 United Kingdom
DJBMASTER
Serious User
|
Serious User
Joined: Nov 2007
Posts: 1,143
United Kingdom
|
Hi, here is a function that allows you to drag a panel across the screen...
public IEnumerable DragPanel()
{
PANEL sender = EngVar.mouse_panel;
int startx = EngVar.mouse_cursor.x.IntValue - sender.pos_x.IntValue;
int starty = EngVar.mouse_cursor.y.IntValue - sender.pos_y.IntValue;
while (EngVar.mouse_left.IntValue == 1)
{
if (EngVar.mouse_moving.IntValue == 1)
{
sender.pos_x.IntValue = EngVar.mouse_cursor.x.IntValue- startx;
sender.pos_y.IntValue = EngVar.mouse_cursor.y.IntValue -starty;
}
yield return 1;
}
}
and it is assigned to a PANEL's 'event' property...
PANEL pnl = EngFun.pan_create("bmap = hi.bmp;",(Var)1);
pnl.pos_x.IntValue = 0;
pnl.pos_y.IntValue = 0;
pnl.event_ = DragPanel;
pnl.SHOW = true;
Maybe i'm doing something wrong or it's a bug or something but i can only ever drag the panel once. So it seems the event function is only being called once. I think the while loop may be a contributing factor because if i just have a function that calls a messageBox, then i can click the panel infinite times and it will show the MessageBox. While we are on the subject. In Lite-C, when you call a PANEL event you can pass the PANEL pointer to the function allowing you to see which panel called the function. I don't know if this is possible with the wrapper because the event property expects an EventVoid signature, so no paramter passing. I do have a workaround with mouse_panel, but it would make things a little easier. Just a thought.
|
|
|
Re: C# wrapper - A7.80 V1.0.2
[Re: Stromausfall]
#285914
08/21/09 14:50
08/21/09 14:50
|
Joined: Dec 2006
Posts: 434 UK,Terra, SolarSystem, Milky W...
pararealist
Senior Member
|
Senior Member
Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
|
@Stromausfall
How to use ent_animate(actor, "idle",percent, ANM_CYCLE);
cant find ANM_CYCLE??
Last edited by pararealist; 08/21/09 14:53.
A8.3x Commercial, AcknexWrapper and VS 2010 Express ○pararealist now.
|
|
|
Re: C# wrapper - A7.80 V1.0.2
[Re: pararealist]
#285927
08/21/09 15:47
08/21/09 15:47
|
Joined: Dec 2002
Posts: 616 Austria
Stromausfall
OP
User
|
OP
User
Joined: Dec 2002
Posts: 616
Austria
|
Hi ! @DJBMASTER: it worked for me, even multiple times, but it seems that one can only drag it if one clicks in the lower right part of the panel ! here's the code i used :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AcknexWrapper;
using System.Collections;
namespace game
{
class Program
{
static IEnumerable mouse()
{
BMAP arrow = EngFun.bmap_create("mouse.bmp");
EngVar.mouse_map = arrow;
EngVar.mouse_mode.IntValue = 2;
while (true)
{
EngVar.mouse_pos.x.FloatValue = EngVar.mouse_cursor.x.FloatValue;
EngVar.mouse_pos.y.FloatValue = EngVar.mouse_cursor.y.FloatValue;
yield return 1;
}
}
public static IEnumerable DragPanel()
{
Console.WriteLine("i was called !");
PANEL sender = EngVar.mouse_panel;
int startx = EngVar.mouse_cursor.x.IntValue - sender.pos_x.IntValue;
int starty = EngVar.mouse_cursor.y.IntValue - sender.pos_y.IntValue;
while (EngVar.mouse_left.IntValue == 1)
{
if (EngVar.mouse_moving.IntValue == 1)
{
sender.pos_x.IntValue = EngVar.mouse_cursor.x.IntValue - startx;
sender.pos_y.IntValue = EngVar.mouse_cursor.y.IntValue - starty;
}
yield return 1;
}
}
static IEnumerable MainMethod()
{
PANEL pnl = EngFun.pan_create("bmap = mouse.bmp;", (Var)1);
pnl.pos_x.IntValue = 0;
pnl.pos_y.IntValue = 0;
pnl.event_ = DragPanel;
pnl.SHOW = true;
yield return 1;
}
static void Main(string[] args)
{
EngFun.engine_open(null);
Scheduler.AddEventVoid(mouse);
Scheduler.StartScheduler(MainMethod);
}
}
}
Didn't knew that the panel event takes a Panel as Parameter, i will add that in the next version of the wrapper thanks ! @pararealist Ah, it seems i have forgotten to add an enum for ent_animate, i will fix that in the next version (which will be released quite soon) !
|
|
|
Re: C# wrapper - A7.80 V1.0.2
[Re: Stromausfall]
#285932
08/21/09 16:07
08/21/09 16:07
|
Joined: Dec 2002
Posts: 616 Austria
Stromausfall
OP
User
|
OP
User
Joined: Dec 2002
Posts: 616
Austria
|
I've just released Version 1.0.3 for a6.60 Version 1.1.1.8 for a7.77 Version 1.0.2 for a7.80
these versions now include the ent_animate flags and the PANEL event now doesn't take an EVENTVOID any longer but an EVENTINTPTR ! Big thanks to DJBMASTER and pararealist ^^
edit: @DJBMASTER lol xD
Last edited by Stromausfall; 08/21/09 16:13.
|
|
|
Re: C# wrapper - A7.80 V1.0.2
[Re: Stromausfall]
#285933
08/21/09 16:07
08/21/09 16:07
|
Joined: Nov 2007
Posts: 1,143 United Kingdom
DJBMASTER
Serious User
|
Serious User
Joined: Nov 2007
Posts: 1,143
United Kingdom
|
ahhh it was because i forgot to continously set the mouse position...
EngVar.mouse_pos.x.IntValue = EngVar.mouse_cursor.x.IntValue;
EngVar.mouse_pos.y.IntValue = EngVar.mouse_cursor.y.IntValue;
So it was always only detecting panels at (0,0). Don't know why you can only drag in the bottom corner, but i'm not using a mouse_map so maybe it limits the 'detection' region. Thanks again. LOL, when you said soon i thought you meant like a day, not a minute, ahahaha. Nice one!
Last edited by DJBMASTER; 08/21/09 16:11.
|
|
|
|