Пример #1
0
    // use lunaStack::push if possible.
    public static void push(Lua.lua_State L, LWF.Button obj, bool gc, Lua.CharPtr metatable = null)
    {
        int objectId = -1;

        if (!objectIdentifiers[L].TryGetValue(obj, out objectId))
        {
            objectId = idOffset++;
            objectIdentifiers[L].Add(obj, objectId);
            objects[L].Add(objectId, obj);
        }

        if (metatable == null)
        {
            metatable = LunaTraits_LWF_Button.className;
        }
        Lua.lua_pushstring(L, "__luna");
        Lua.lua_gettable(L, Lua.LUA_GLOBALSINDEX);
        int __luna = Lua.lua_gettop(L);

        Luna.userdataType ud = new Luna.userdataType(
            objectId: objectId,  // store object in userdata
            gc: gc,              // collect garbage
            has_env: false,      // does this userdata has a table attached to it?
            typeId: LunaTraits_LWF_Button.uniqueID
            );

        ud.ToBytes((byte[])Lua.lua_newuserdata(L, Luna.userdataType.Size));

        Lua.lua_pushstring(L, metatable);
        Lua.lua_gettable(L, __luna);
        Lua.lua_setmetatable(L, -2);
        //Luna.printStack(L);
        Lua.lua_insert(L, -2);          // swap __luna and userdata
        Lua.lua_pop(L, 1);
    }
Пример #2
0
    }                                // hide default constructor

    // create a new T object and
    // push onto the Lua stack a userdata containing a pointer to T object
    private static int new_T(Lua.lua_State L)
    {
        Lua.lua_remove(L, 1);                                 // use classname:new(), instead of classname.new()
        LWF.Button obj = LunaTraits_LWF_Button._bind_ctor(L); // call constructor for T objects
        push(L, obj, true);
        return(1);                                            // userdata containing pointer to T object
    }
Пример #3
0
    public static void Destroy(Lua.lua_State L, LWF.Button obj)
    {
        int objectId = -1;

        if (objectIdentifiers[L].TryGetValue(obj, out objectId))
        {
            objectIdentifiers[L].Remove(obj);
            objects[L].Remove(objectId);
        }
    }
Пример #4
0
 public static int _bind_getParent(Lua.lua_State L)
 {
     if (Lua.lua_gettop(L) != 1 || Luna.get_uniqueid(L, 1) !=
         LunaTraits_LWF_Button.uniqueID)
     {
         Luna.printStack(L);
         Lua.luaL_error(L, "luna typecheck failed: LWF.Button.parent");
     }
     LWF.Button a = Luna_LWF_Button.check(L, 1);
     Luna_LWF_Movie.push(L, a.parent, false);
     return(1);
 }
Пример #5
0
    public static int addEventListener(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 3 ||
            Luna.get_uniqueid(L, 1) != LunaTraits_LWF_Button.uniqueID ||
            Lua.lua_isstring(L, 2) == 0 || !Lua.lua_isfunction(L, 3))
        {
            Luna.printStack(L);
            Lua.luaL_error(L, "luna typecheck failed: LWF.Button.addEventListener");
        }

        LWF.Button a = Luna_LWF_Button.check(L, 1);
        return(a.lwf.AddEventHandlerLua(null, a));
    }
Пример #6
0
    private static int tostring_T(Lua.lua_State L)
    {
        Luna.userdataType ud  = (Luna.userdataType)Lua.lua_touserdata(L, 1);
        LWF.Button        obj = null;
        if (!objects[L].TryGetValue(ud.ObjectId, out obj))
        {
            return(0);
        }

        char[] buff = obj.ToString().ToCharArray(0, 32);
        Lua.lua_pushfstring(L, "%s (%s)", new object[] { LunaTraits_LWF_Button.className, buff });
        return(1);
    }
Пример #7
0
 public static int _bind_getHeight(Lua.lua_State L)
 {
     if (Lua.lua_gettop(L) != 1 ||
         Luna.get_uniqueid(L, 1) != 8952431)
     {
         Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:getHeight(LWF.Button self ...)");
     }
     LWF.Button o = Luna_LWF_Button.check(L, 1);
     try {
         float ret = getHeight(o);
         Lua.lua_pushnumber(L, ret);
     } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
     return(1);
 }
Пример #8
0
    public static int _bind_getFullName(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 1 ||
            Luna.get_uniqueid(L, 1) != 8952431)
        {
            Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:getFullName(LWF.Button self)");
        }

        LWF.Button self = Luna_LWF_Button.check(L, 1);
        try {
            string ret = self.GetFullName();
            Lua.lua_pushstring(L, ret);
        } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
        return(1);
    }
Пример #9
0
    public static int __index(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) == 2 && Luna.get_uniqueid(L, 1) ==
            LunaTraits_LWF_Movie.uniqueID)
        {
            LWF.Movie o =
                Luna_LWF_Movie.check(L, 1);
            string name = Lua.lua_tostring(L, 2).ToString();
            if (o.lwf.GetFieldLua(o, name))
            {
                return(1);
            }
            LWF.Movie movie = o.SearchMovieInstance(name, false);
            if (movie != null)
            {
                Lua.lua_pop(L, 1);
                Luna_LWF_Movie.push(L, movie, false);
                return(1);
            }
            LWF.Button button = o.SearchButtonInstance(name, false);
            if (button != null)
            {
                Lua.lua_pop(L, 1);
                Luna_LWF_Button.push(L, button, false);
                return(1);
            }
        }


        {
            Lua.lua_CFunction fnc = null;
            if (LunaTraits_LWF_Movie.properties.TryGetValue(Lua.lua_tostring(L, 2).ToString(), out fnc))
            {
                Lua.lua_pop(L, 1);                // remove self
                return(fnc(L));
            }
        }

        int mt = Lua.lua_getmetatable(L, 1);

        if (mt == 0)
        {
            Lua.luaL_error(L, "__index");             //end
        }
        Lua.lua_pushstring(L, Lua.lua_tostring(L, 2));
        Lua.lua_rawget(L, -2);
        return(1);
    }
Пример #10
0
    public static int _bind_clearEventListener(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 2 ||
            Luna.get_uniqueid(L, 1) != 8952431 ||
            Lua.lua_isstring(L, 2) == 0)
        {
            Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:clearEventListener(LWF.Button self)");
        }

        LWF.Button self      = Luna_LWF_Button.check(L, 1);
        string     eventName = Lua.lua_tostring(L, 2).ToString();

        try {
            self.ClearEventHandler(eventName);
        } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
        return(0);
    }
Пример #11
0
    // garbage collection metamethod
    private static int gc_T(Lua.lua_State L)
    {
        Luna.userdataType ud = (Luna.userdataType)Lua.lua_touserdata(L, 1);

        LWF.Button obj = null;
        if (!objects[L].TryGetValue(ud.ObjectId, out obj))
        {
            return(0);
        }

        if (ud.Gc)
        {
            LunaTraits_LWF_Button._bind_dtor(obj);              // call constructor for T objects
        }
        Destroy(L, obj);
        return(0);
    }
Пример #12
0
    private static int tostring_T(Lua.lua_State L)
    {
        byte[] d = (byte[])Lua.lua_touserdata(L, 1);
        if (d == null)
        {
            Luna.print("checkRaw: ud==nil\n"); Lua.luaL_typerror(L, 1, LunaTraits_LWF_Button.className);
        }
        Luna.userdataType ud  = new Luna.userdataType(d);
        LWF.Button        obj = null;
        if (!objects[L].TryGetValue(ud.ObjectId, out obj))
        {
            return(0);
        }

        char[] buff = obj.ToString().ToCharArray(0, 32);
        Lua.lua_pushfstring(L, "%s (%s)", new object[] { LunaTraits_LWF_Button.className, buff });
        return(1);
    }
Пример #13
0
 static public LWF.Button check(Lua.lua_State L, int narg)
 {
     byte[] d = (byte[])Lua.lua_touserdata(L, narg);
     if (d == null)
     {
         Luna.print("checkRaw: ud==nil\n"); Lua.luaL_typerror(L, narg, LunaTraits_LWF_Button.className);
     }
     Luna.userdataType ud = new Luna.userdataType(d);
     if (ud.TypeId != LunaTraits_LWF_Button.uniqueID)       // type checking with almost no overhead
     {
         Luna.print(String.Format("ud.uid: {0} != interface::uid : {1}\n", ud.TypeId, LunaTraits_LWF_Button.uniqueID));
         Lua.luaL_typerror(L, narg, LunaTraits_LWF_Button.className);
     }
     LWF.Button obj = null;
     if (!objects[L].TryGetValue(ud.ObjectId, out obj))
     {
         return(null);
     }
     return(obj);
 }
Пример #14
0
    void DrawButton(LWF.Button button, Factory factory)
    {
        Matrix4x4 savedMatrix = GUI.matrix;
        Color     savedColor  = GUI.color;

        factory.ConvertMatrix(ref matrix, button.matrix, 0, button.height);
        Factory.MultiplyMatrix(ref renderMatrix,
                               factory.gameObject.transform.localToWorldMatrix, matrix);
        Camera camera = factory.camera;

        Matrix4x4 m  = renderMatrix;
        Vector2   lt = GUIUtility.ScreenToGUIPoint(camera.WorldToScreenPoint(
                                                       m.MultiplyPoint(new Vector3(0, button.height))));
        Vector2 rt = GUIUtility.ScreenToGUIPoint(camera.WorldToScreenPoint(
                                                     m.MultiplyPoint(new Vector3(button.width, button.height))));
        Vector2 ld = GUIUtility.ScreenToGUIPoint(camera.WorldToScreenPoint(
                                                     m.MultiplyPoint(new Vector3(0, 0))));

        float dx = rt.x - lt.x;
        float dy = rt.y - lt.y;
        float w  = Mathf.Sqrt(dx * dx + dy * dy);

        dx = ld.x - lt.x;
        dy = ld.y - lt.y;
        float h     = Mathf.Sqrt(dx * dx + dy * dy);
        float angle =
            Mathf.Atan2(rt.x - lt.x, rt.y - lt.y) * Mathf.Rad2Deg - 90;

        lt.y = Screen.height - lt.y;
        GUIUtility.RotateAroundPivot(angle, lt);

        GUI.color = button == button.lwf.focus ?
                    LWFObjectInspector.focusButtonColor :
                    LWFObjectInspector.buttonColor;
        GUI.DrawTexture(new Rect(lt.x, lt.y, w, h), texture);

        GUI.matrix = savedMatrix;
        GUI.color  = savedColor;
    }
Пример #15
0
    // garbage collection metamethod
    private static int gc_T(Lua.lua_State L)
    {
        byte[] d = (byte[])Lua.lua_touserdata(L, 1);
        if (d == null)
        {
            Luna.print("checkRaw: ud==nil\n"); Lua.luaL_typerror(L, 1, LunaTraits_LWF_Button.className);
        }
        Luna.userdataType ud = new Luna.userdataType(d);

        LWF.Button obj = null;
        if (!objects[L].TryGetValue(ud.ObjectId, out obj))
        {
            return(0);
        }

        if (ud.Gc)
        {
            LunaTraits_LWF_Button._bind_dtor(obj);              // call constructor for T objects
            Destroy(L, obj);
        }

        return(0);
    }
Пример #16
0
 public override void LinkButton()
 {
     m_buttonLink = m_lwf.buttonHead;
     m_lwf.buttonHead = this;
 }
Пример #17
0
	public void DispatchEvent(string eventName, Movie m = null, Button b = null)
	{
		if (m == null)
			m = m_rootMovie;
		int eventId = SearchEventId(eventName);
		if (eventId >= 0 && eventId < m_data.events.Length) {
			EventHandlerDictionary dict =
				new EventHandlerDictionary(m_eventHandlers[eventId]);
			foreach (var h in dict)
				h.Value(m, b);
		} else {
			EventHandlerDictionary dict = new EventHandlerDictionary(
				m_genericEventHandlerDictionary[eventName]);
			foreach (var h in dict)
				h.Value(m, b);
		}
	}
Пример #18
0
        public ButtonEventHandlers GetButtonEventHandlers(Button b)
        {
            if (m_buttonEventHandlersByFullName != null) {
            string fullName = b.GetFullName();
            if (fullName != null) {
                ButtonEventHandlers handlers;
                if (m_buttonEventHandlersByFullName.TryGetValue(
                        fullName, out handlers)) {
                    return handlers;
                }
            }
            }

            int instId = b.instanceId;
            if (instId < 0 || instId >= m_instances.Length)
            return null;
            return m_buttonEventHandlers[instId];
        }
Пример #19
0
	public int AddEventHandlerLua(Movie movie = null, Button button = null)
	{
		if (luaState==null)
			return 0;

		Lua.lua_State l = (Lua.lua_State)luaState;
		string ev;
		int luaHandlerId;
		int handlerId;

		/* 1: LWF_LWF instance */
		/* 2: string */
		/* 3: function */
		ev = Lua.lua_tostring(l, 2).ToString();

		Lua.lua_getglobal(l, "LWF");
		/* -1: LWF */
		if (!Lua.lua_istable(l, -1)) {
			Lua.lua_pop(l, 1);
			/* 0 */
			goto error;
		}
		Lua.lua_getfield(l, -1, "Instances");
		/* -2: LWF */
		/* -1: LWF.Instances */
		Lua.lua_remove(l, -2);
		/* -1: LWF.Instances */
		if (!Lua.lua_istable(l, -1)) {
			Lua.lua_pop(l, 1);
			/* 0 */
			goto error;
		}
		Lua.lua_getfield(l, -1, instanceIdString);
		/* -2: LWF.Instances */
		/* -1: LWF.Instances.<instanceId> */
		Lua.lua_remove(l, -2);
		/* -1: LWF.Instances.<instanceId> */
		if (!Lua.lua_istable(l, -1)) {
			Lua.lua_pop(l, 1);
			/* 0 */
			goto error;
		}
		Lua.lua_getfield(l, -1, "Handlers");
		/* -2: LWF.Instances.<instanceId> */
		/* -1: LWF.Instances.<instanceId>.Handlers */
		Lua.lua_remove(l, -2);
		/* -1: LWF.Instances.<instanceId>.Handlers */
		if (!Lua.lua_istable(l, -1)) {
			Lua.lua_pop(l, 1);
			/* 0 */
			goto error;
		}
		Lua.lua_pushvalue(l, 3);
		/* -2: LWF.Instances.<instanceId>.Handlers */
		/* -1: function */
		luaHandlerId = GetEventOffset();
		Lua.lua_setfield(l, -2, luaHandlerId.ToString());
		/* LWF.Instances.<instanceId>.Handlers.<luaHandlerId> = function */
		/* -1: LWF.Instances.<instanceId>.Handlers */
		Lua.lua_pop(l, 1);
		/* 0 */

		if (movie != null) {
			if (string.IsNullOrEmpty(ev) || MovieEvents.ContainsKey(ev)) {
				/* Movie event */
				handlerId = movie.AddEventHandler(ev, (Movie m) => {
					Lua.lua_State _l = (Lua.lua_State)m.lwf.luaState;
					if (!m.lwf.PushHandlerLua(luaHandlerId))
						return;
					/* -1: function */

					Luna_LWF_Movie.push(_l, m, false);
					/* -2: function */
					/* -1: Movie */
					if (Lua.lua_pcall(_l, 1, 0, 0)!=0)
						Lua.lua_pop(_l, 1);
				});
			} else {
				handlerId = movie.AddEventHandler(ev, () => {
					Lua.lua_State _l = (Lua.lua_State)movie.lwf.luaState;
					if (!movie.lwf.PushHandlerLua(luaHandlerId))
						return;
					/* -1: function */

					/* User defined event */
					Lua.lua_createtable(_l, 0, 2);
					/* -2: function */
					/* -1: table */
					Lua.lua_pushstring(_l, ev);
					/* -3: function */
					/* -2: table */
					/* -1: string(type) */
					Lua.lua_setfield(_l, -2, "type");
					/* -2: function */
					/* -1: table */
					if (Lua.lua_istable(_l, 2)) {
						Lua.lua_getfield(_l, 2, "param");
						/* -3: function */
						/* -2: table */
						/* -1: param */
					} else {
						Lua.lua_pushnil(_l);
						/* -3: function */
						/* -2: table */
						/* -1: nil */
					}
					Lua.lua_setfield(_l, -2, "param");
					/* -2: function */
					/* -1: table */
					if (Lua.lua_pcall(_l, 1, 0, 0)!=0)
						Lua.lua_pop(_l, 1);
					/* 0 */
				});
			}
		} else if (button != null) {
			if (string.Compare(ev, "keyPress") == 0) {
				handlerId = button.AddEventHandler(ev, (Button b, int k) => {
					if (!b.lwf.PushHandlerLua(luaHandlerId))
						return;

					/* -1: function */
					Lua.lua_State _l = (Lua.lua_State)b.lwf.luaState;
					Luna_LWF_Button.push(_l, b, false);
					Lua.lua_pushnumber(_l, k);
					/* -3: function */
					/* -2: Button */
					/* -1: int */
					if (Lua.lua_pcall(l, 2, 0, 0)!=0)
						Lua.lua_pop(l, 1);
					/* 0 */
				});
			} else {
				handlerId = button.AddEventHandler(ev, (Button b) => {
					if (!b.lwf.PushHandlerLua(luaHandlerId))
						return;

					/* -1: function */
					Lua.lua_State _l = (Lua.lua_State)b.lwf.luaState;
					Luna_LWF_Button.push(_l, b, false);
					/* -2: function */
					/* -1: Button */
					if (Lua.lua_pcall(l, 1, 0, 0)!=0)
						Lua.lua_pop(l, 1);
					/* 0 */
				});
			}
		} else {
			handlerId = AddEventHandler(ev, (Movie m, Button b) => {
				if (!m.lwf.PushHandlerLua(luaHandlerId))
					return;

				/* -1: function */
				Lua.lua_State _l = (Lua.lua_State)m.lwf.luaState;
				Luna_LWF_Movie.push(_l, m, false);
				Luna_LWF_Button.push(_l, b, false);
				/* -3: function */
				/* -2: Movie */
				/* -1: Button */
				if (Lua.lua_pcall(l, 2, 0, 0)!=0)
					Lua.lua_pop(l, 1);
				/* 0 */
			});
		}

		Lua.lua_pushnumber(l, handlerId);
		/* -1: handlerId */
		return 1;

	error:
		Lua.lua_pushnumber(l, -1);
		/* -1: -1 */
		return 1;
	}
Пример #20
0
	public void PlayAnimation(
		int animationId, Movie movie, Button button = null)
	{
		int i = 0;
		int[] animations = m_data.animations[animationId];
		Movie target = movie;

		for (;;) {
			switch ((Animation)animations[i++]) {
			case Animation.END:
				return;

			case Animation.PLAY:
				target.Play();
				break;

			case Animation.STOP:
				target.Stop();
				break;

			case Animation.NEXTFRAME:
				target.NextFrame();
				break;

			case Animation.PREVFRAME:
				target.PrevFrame();
				break;

			case Animation.GOTOFRAME:
				target.GotoFrameInternal(animations[i++]);
				break;

			case Animation.GOTOLABEL:
				target.GotoFrame(SearchFrame(target, animations[i++]));
				break;

			case Animation.SETTARGET:
				{
					target = movie;

					int count = animations[i++];
					if (count == 0)
						break;

					for (int j = 0; j < count; ++j) {
						int instId = animations[i++];

						switch ((Animation)instId) {
						case Animation.INSTANCE_TARGET_ROOT:
							target = m_rootMovie;
							break;

						case Animation.INSTANCE_TARGET_PARENT:
							target = target.parent;
							if (target == null)
								target = m_rootMovie;
							break;

						default:
							{
								target = target.SearchMovieInstanceByInstanceId(
									instId, false);
								if (target == null)
									target = movie;
								break;
							}
						}
					}
				}
				break;

			case Animation.EVENT:
				{
					int eventId = animations[i++];
#if LWF_USE_LUA
					CallEventFunctionLua(eventId, movie, button);
#endif
					if (m_eventHandlers[eventId] != null) {
						var handlers = new EventHandlerDictionary(
							m_eventHandlers[eventId]);
						foreach (var h in handlers)
							h.Value(movie, button);
					}
				}
				break;

			case Animation.CALL:
#if LWF_USE_LUA
				{
					int stringId = animations[i++];
					if (stringId < 0 || stringId >= data.strings.Length)
						break;
					CallFunctionLua(data.strings[stringId], target);
				}
#else
				i++;
#endif
				break;
			}
		}
	}
Пример #21
0
 public void ClearPressed(Button button)
 {
     if (m_pressed == button)
     m_pressed = null;
 }
Пример #22
0
        public void Init()
        {
            m_time = 0;
            m_progress = 0;

            Array.Clear(m_instances, 0, m_instances.Length);
            m_focus = null;

            m_movieCommands.Clear();

            m_rootMovieStringId = GetStringId("_root");
            if (m_rootMovie != null)
            m_rootMovie.Destroy();
            m_rootMovie = new Movie(this, null,
            m_data.header.rootMovieId, SearchInstanceId(m_rootMovieStringId));
        }
Пример #23
0
 public static float getHitY(LWF.Button o)
 {
     return(o.hitY);
 }
Пример #24
0
 public static float getWidth(LWF.Button o)
 {
     return(o.width);
 }
Пример #25
0
	public void Call(Type type, Button target)
	{
		ButtonEventHandlerDictionary dict = null; 
		switch (type) {
		case Type.LOAD: dict = load; break;
		case Type.UNLOAD: dict = unload; break;
		case Type.ENTERFRAME: dict = enterFrame; break;
		case Type.UPDATE: dict = update; break;
		case Type.RENDER: dict = render; break;
		case Type.PRESS: dict = press; break;
		case Type.RELEASE: dict = release; break;
		case Type.ROLLOVER: dict = rollOver; break;
		case Type.ROLLOUT: dict = rollOut; break;
		}
		if (dict != null) {
			dict = new ButtonEventHandlerDictionary(dict);
			foreach (var h in dict)
				h.Value(target);
		}
	}
Пример #26
0
 public void CallKEYPRESS(Button target, int code)
 {
     keyPress.ForEach(h => h(target, code));
 }
Пример #27
0
	public void CallKEYPRESS(Button target, int code)
	{
		ButtonKeyPressHandlerList list =
			new ButtonKeyPressHandlerList(keyPress);
		list.ForEach(h => h(target, code));
	}
Пример #28
0
	public void CallKEYPRESS(Button target, int code)
	{
		ButtonKeyPressHandlerDictionary dict =
			new ButtonKeyPressHandlerDictionary(keyPress);
		foreach (var h in dict)
			h.Value(target, code);
	}
Пример #29
0
 public static void _bind_dtor(LWF.Button obj)
 {
 }
Пример #30
0
        private void ExecObject(int dlDepth, int objId,
		int matrixId, int colorTransformId, int instId,
		int dlBlendMode, bool updateBlendMode = false)
        {
            // Ignore error
            if (objId == -1)
            return;
            Data data = m_lwf.data;
            Format.Object dataObject = data.objects[objId];
            int dataObjectId = dataObject.objectId;
            Object obj = m_displayList[dlDepth];

            if (obj != null && (obj.type != (Type)dataObject.objectType ||
                obj.objectId != dataObjectId || (obj.IsMovie() &&
                ((IObject)obj).instanceId != instId))) {
            if (m_texts != null && obj.IsText())
                EraseText(obj.objectId);
            obj.Destroy();
            obj = null;
            }

            if (obj == null) {
            switch ((Type)dataObject.objectType) {
            case Type.BUTTON:
                obj = new Button(m_lwf,
                    this, dataObjectId, instId, matrixId, colorTransformId);
                break;

            case Type.GRAPHIC:
                obj = new Graphic(m_lwf, this, dataObjectId);
                break;

            case Type.MOVIE:
                obj = new Movie(m_lwf, this,
                    dataObjectId, instId, matrixId, colorTransformId);
                ((Movie)obj).blendMode = dlBlendMode;
                break;

            case Type.BITMAP:
                obj = new Bitmap(m_lwf, this, dataObjectId);
                break;

            case Type.BITMAPEX:
                obj = new BitmapEx(m_lwf, this, dataObjectId);
                break;

            case Type.TEXT:
                obj = new Text(m_lwf, this, dataObjectId, instId);
                break;

            case Type.PARTICLE:
                obj = new Particle(m_lwf, this, dataObjectId);
                break;

            case Type.PROGRAMOBJECT:
                obj = new ProgramObject(m_lwf, this, dataObjectId);
                break;
            }
            }

            if (obj.IsMovie() && updateBlendMode)
            ((Movie)obj).blendMode = dlBlendMode;

            if (obj.IsMovie() || obj.IsButton()) {
            IObject instance = (IObject)obj;
            instance.linkInstance = null;
            if (m_instanceHead == null)
                m_instanceHead = instance;
            else
                m_instanceTail.linkInstance = instance;
            m_instanceTail = instance;
            if (obj.IsButton())
                m_hasButton = true;
            }

            if (m_texts != null && obj.IsText())
            InsertText(obj.objectId);

            m_displayList[dlDepth] = obj;
            obj.execCount = m_movieExecCount;
            obj.Exec(matrixId, colorTransformId);
        }
Пример #31
0
 public static float getHeight(LWF.Button o)
 {
     return(o.height);
 }
Пример #32
0
 public void ClearFocus(Button button)
 {
     if (m_focus == button)
     m_focus = null;
 }
Пример #33
0
	public override void LinkButton()
	{
		if (m_lwf.focus == this)
			m_lwf.focusOnLink = true;
		m_buttonLink = m_lwf.buttonHead;
		m_lwf.buttonHead = this;
	}
Пример #34
0
        public int Exec(float tick = 0,
		Matrix matrix = null, ColorTransform colorTransform = null)
        {
            bool execed = false;
            float currentProgress = m_progress;
            m_thisTick = tick;

            if (m_execDisabled && tweens == null) {
            if (!m_executedForExecDisabled) {
                ++m_execCount;
                m_rootMovie.Exec();
                m_rootMovie.PostExec(true);
                m_executedForExecDisabled = true;
                execed = true;
            }
            } else {
            bool progressing = true;
            if (tick == 0) {
                m_progress = m_tick;
            } else if (tick < 0) {
                m_progress = m_tick;
                progressing = false;
            } else {
                if (m_time == 0) {
                    m_time += (double)m_tick;
                    m_progress += m_tick;
                } else {
                    m_time += (double)tick;
                    m_progress += tick;
                }
            }

            if (m_execHandlers != null)
                m_execHandlers.ForEach(h => h(this));

            int execLimit = m_execLimit;
            while (m_progress >= m_tick - m_roundOffTick) {
                if (--execLimit < 0) {
                    m_progress = 0;
                    break;
                }
                m_progress -= m_tick;
                ++m_execCount;
                m_rootMovie.Exec();
                m_rootMovie.PostExec(progressing);
                execed = true;
            }

            if (m_progress < m_roundOffTick)
                m_progress = 0;

            m_buttonHead = null;
            if (interactive && m_rootMovie.hasButton)
                m_rootMovie.LinkButton();
            }

            if (execed || isLWFAttached ||
                isPropertyDirty || matrix != null || colorTransform != null)
            Update(matrix, colorTransform);

            if (!m_execDisabled) {
            if (tick < 0)
                m_progress = currentProgress;
            }

            return m_renderingCount;
        }
Пример #35
0
 public void DispatchEvent(string eventName, Movie m = null, Button b = null)
 {
     if (m == null)
     m = m_rootMovie;
     int eventId = SearchEventId(eventName);
     if (eventId >= 0 && eventId < m_data.events.Length) {
     EventHandlerList list =
         new EventHandlerList(m_eventHandlers[eventId]);
     list.ForEach(h => h(m, b));
     } else {
     EventHandlerList list = new EventHandlerList(
         m_genericEventHandlerDictionary[eventName]);
     foreach (EventHandler h in list)
         h(m, b);
     }
 }
Пример #36
0
	public void CallEventFunctionLua(int eventId, Movie movie, Button button)
	{
		if (luaState==null)
			return;

		if (!m_eventFunctions.ContainsKey(eventId))
			return;

		Lua.lua_State l = (Lua.lua_State)luaState;
		Lua.lua_getglobal(l, "LWF");
		/* -1: LWF */
		if (!Lua.lua_istable(l, -1)) {
			Lua.lua_pop(l, 1);
			/* 0 */
			return;
		}
		Lua.lua_getfield(l, -1, "Script");
		/* -2: LWF */
		/* -1: LWF.Script */
		Lua.lua_remove(l, -2);
		/* -1: LWF.Script */
		if (!Lua.lua_istable(l, -1)) {
			Lua.lua_pop(l, 1);
			/* 0 */
			return;
		}
		Lua.lua_getfield(l, -1, name);
		/* -2: LWF.Script */
		/* -1: LWF.Script.<name> */
		Lua.lua_remove(l, -2);
		/* -1: LWF.Script.<name> */
		if (!Lua.lua_istable(l, -1)) {
			Lua.lua_pop(l, 1);
			/* 0 */
			return;
		}
		string ev = "Event_";
		Lua.lua_getfield(l, -1,
			(ev + data.strings[data.events[eventId].stringId]));
		/* -2: LWF.Script.<name> */
		/* -1: LWF.Script.<name>.Event_<eventName> */
		Lua.lua_remove(l, -2);
		/* -1: LWF.Script.<name>.Event_<eventName>*/

		if (!Lua.lua_isfunction(l, -1)) {
			Lua.lua_pop(l, 1);
			/* 0 */
			return;
		}
		Luna_LWF_Movie.push(l, movie, false);
		/* -2: LWF.Script.<name>.Event_<eventName> */
		/* -1: LWF_Movie instance */
		Luna_LWF_Button.push(l, button, false);
		/* -3: LWF.Script.<name>.Event_<eventName> */
		/* -2: LWF_Movie instance */
		/* -1: LWF_Button instance */
		if (Lua.lua_pcall(l, 2, 0, 0)!=0)
			Lua.lua_pop(l, 1);
		/* 0 */
	}
Пример #37
0
	private void LinkButton()
	{
		m_buttonHead = null;
		if (interactive && m_rootMovie.hasButton) {
			m_focusOnLink = false;
			m_rootMovie.LinkButton();
			if (m_focus != null && !m_focusOnLink) {
				m_focus.RollOut();
				m_focus = null;
			}
		}
	}
Пример #38
0
	public void Call(Type type, Button target)
	{
		ButtonEventHandlerList list = null; 
		switch (type) {
		case Type.LOAD: list = load; break;
		case Type.UNLOAD: list = unload; break;
		case Type.ENTERFRAME: list = enterFrame; break;
		case Type.UPDATE: list = update; break;
		case Type.RENDER: list = render; break;
		case Type.PRESS: list = press; break;
		case Type.RELEASE: list = release; break;
		case Type.ROLLOVER: list = rollOver; break;
		case Type.ROLLOUT: list = rollOut; break;
		}
		if (list != null) {
			list = new ButtonEventHandlerList(list);
			list.ForEach(h => h(target));
		}
	}
Пример #39
0
 static void handler(LWF.Movie movie, LWF.Button button)
 {
     Debug.Log("FINISH");
 }
Пример #40
0
    void DrawInspector(ObjectContainer container)
    {
        EditorGUI.indentLevel = container.hierarchy + 1;

        LWF.Object obj = container.obj;
        LWF.LWF    lwf = obj.lwf;
        if (obj.type == Type.MOVIE)
        {
            LWF.Movie movie = (LWF.Movie)obj;

            string movieName = "Movie: " +
                               (movie.name == null ? "(null)" : movie.name);
            if (!visibilities.ContainsKey(movie))
            {
                visibilities[movie] = true;
            }
            visibilities[movie] =
                EditorGUILayout.Foldout(visibilities[movie], movieName);

            if (!visibilities[movie])
            {
                return;
            }

            EditorGUI.indentLevel = container.hierarchy + 2;
            string fullName = movie.GetFullName();
            if (fullName == null)
            {
                fullName = "(null)";
            }
            EditorGUILayout.LabelField("Fullname:", fullName);
            EditorGUILayout.LabelField("Visible:", movie.visible.ToString());
            EditorGUILayout.LabelField("Playing:", movie.playing.ToString());
            EditorGUILayout.LabelField("Frame:", movie.currentFrame.ToString());
            DrawInfo(container, movie);

            // TODO
            EditorGUILayout.Space();

            foreach (KeyValuePair <int, ObjectContainer>
                     kvp in container.objects)
            {
                DrawInspector(kvp.Value);
            }
        }
        else
        {
            EditorGUILayout.LabelField("Depth:", container.depth.ToString());
            EditorGUI.indentLevel = container.hierarchy + 2;

            switch (obj.type)
            {
            case Type.BUTTON:
                LWF.Button button     = (LWF.Button)obj;
                string     buttonName =
                    (button.name == null ? "(null)" : button.name);
                string buttonFullName = button.GetFullName();
                if (buttonFullName == null)
                {
                    buttonFullName = "(null)";
                }
                EditorGUILayout.LabelField("Button:", buttonName);

                EditorGUI.indentLevel = container.hierarchy + 3;
                EditorGUILayout.LabelField("Fullname:", buttonFullName);
                DrawInfo(container, obj);
                // TODO
                break;

            case Type.GRAPHIC:
                EditorGUILayout.LabelField("Graphic:", "");
                EditorGUI.indentLevel = container.hierarchy + 3;
                DrawInfo(container, obj);
                // TODO
                break;

            case Type.BITMAP:
                LWF.Bitmap bitmap      = (LWF.Bitmap)obj;
                int        tFId        = lwf.data.bitmaps[bitmap.objectId].textureFragmentId;
                string     textureName = (tFId == -1 ? "(null)" :
                                          lwf.data.textureFragments[tFId].filename);
                EditorGUILayout.LabelField("Bitmap:", textureName);
                EditorGUI.indentLevel = container.hierarchy + 3;
                DrawInfo(container, obj);
                // TODO
                break;

            case Type.BITMAPEX:
                LWF.BitmapEx bitmapEx = (LWF.BitmapEx)obj;
                int          tFIdEx   =
                    lwf.data.bitmapExs[bitmapEx.objectId].textureFragmentId;
                string textureNameEx = (tFIdEx == -1 ? "(null)" :
                                        lwf.data.textureFragments[tFIdEx].filename);
                EditorGUILayout.LabelField("BitmapEx:", textureNameEx);
                EditorGUI.indentLevel = container.hierarchy + 3;
                DrawInfo(container, obj);
                // TODO
                break;

            case Type.TEXT:
                LWF.Text text     = (LWF.Text)obj;
                string   textName = lwf.data.strings[
                    lwf.data.texts[text.objectId].nameStringId];
                EditorGUILayout.LabelField("Text:", textName);
                EditorGUI.indentLevel = container.hierarchy + 3;
                DrawInfo(container, obj);
                // TODO
                break;

            case Type.PARTICLE:
                EditorGUILayout.LabelField("Particle:", "");
                EditorGUI.indentLevel = container.hierarchy + 3;
                DrawInfo(container, obj);
                // TODO
                break;

            case Type.PROGRAMOBJECT:
                LWF.ProgramObject pObject     = (LWF.ProgramObject)obj;
                string            pObjectName = lwf.data.strings[
                    lwf.data.programObjects[pObject.objectId].stringId];
                EditorGUILayout.LabelField("ProgramObject:", pObjectName);
                EditorGUI.indentLevel = container.hierarchy + 3;
                DrawInfo(container, obj);
                // TODO
                break;
            }
        }
    }
Пример #41
0
 public static string getName(LWF.Button o)
 {
     return(o.name);
 }
Пример #42
0
    void OnGUI()
    {
        LWFObject[] lwfObjects =
            FindObjectsOfType(typeof(LWFObject)) as LWFObject[];
        if (lwfObjects == null)
        {
            return;
        }

        if (!texture)
        {
            texture = new Texture2D(1, 1);
            texture.SetPixel(0, 0, Color.white);
            texture.Apply();
        }

        Matrix4x4 savedMatrix = GUI.matrix;
        Color     savedColor  = GUI.color;

        foreach (LWFObject lwfObject in lwfObjects)
        {
            bool visibility;
            if (visibilities.TryGetValue(
                    lwfObject, out visibility) && !visibility)
            {
                continue;
            }

            LWF.LWF lwf = lwfObject.lwf;
            if (lwf == null)
            {
                continue;
            }

            lwf.Inspect((obj, hierarchy, depth, rOffset) => {
                if (obj.type != Type.BUTTON)
                {
                    return;
                }

                for (LWF.Object o = obj.parent; o != null; o = o.parent)
                {
                    LWF.Movie m = o as LWF.Movie;
                    if (m != null && !m.visible)
                    {
                        return;
                    }
                    if (visibilities.TryGetValue(
                            o, out visibility) && !visibility)
                    {
                        return;
                    }
                }

                Factory factory = lwf.rendererFactory as Factory;
                if (factory == null)
                {
                    return;
                }

                LWF.Button button = (LWF.Button)obj;
                DrawButton(button, factory);
            });
        }

        GUI.matrix = savedMatrix;
        GUI.color  = savedColor;
    }
Пример #43
0
 public void Call(Type type, Button target)
 {
     switch (type) {
     case Type.LOAD: load.ForEach(h => h(target)); break;
     case Type.UNLOAD: unload.ForEach(h => h(target)); break;
     case Type.ENTERFRAME: enterFrame.ForEach(h => h(target)); break;
     case Type.UPDATE: update.ForEach(h => h(target)); break;
     case Type.RENDER: render.ForEach(h => h(target)); break;
     case Type.PRESS: press.ForEach(h => h(target)); break;
     case Type.RELEASE: release.ForEach(h => h(target)); break;
     case Type.ROLLOVER: rollOver.ForEach(h => h(target)); break;
     case Type.ROLLOUT: rollOut.ForEach(h => h(target)); break;
     }
 }