public uint LowTextManager(ByteAccess ascii, int width, byte pen) { _textCount++; if (_textCount > MaxTextObs) { throw new InvalidOperationException("Text::lowTextManager: MAX_TEXT_OBS exceeded"); } uint textObjId = ObjectMan.TEXT_sect * ObjectMan.ITM_PER_SEC - 1; do { textObjId++; } while (_objMan.FetchObject(textObjId).status != 0); // okay, found a free text object _objMan.FetchObject(textObjId).status = Logic.STAT_FORE; MakeTextSprite((byte)textObjId, ascii, (ushort)width, pen); return(textObjId); }
public void Engine(ushort x, ushort y, ushort eventFlags) { _state = 0; // all mouse events are flushed after one cycle. if (_lastState != 0) { // delay all events by one cycle to notice L_button + R_button clicks correctly. _state = (ushort)(_lastState | eventFlags); _lastState = 0; } else if (eventFlags != 0) { _lastState = eventFlags; } // if we received both, mouse down and mouse up event in this cycle, resort them so that // we'll receive the up event in the next one. if ((_state & MOUSE_DOWN_MASK) != 0 && (_state & MOUSE_UP_MASK) != 0) { _lastState = (ushort)(_state & MOUSE_UP_MASK); _state &= MOUSE_DOWN_MASK; } _mouse.X = x; _mouse.Y = y; if ((Logic.ScriptVars[(int)ScriptVariableNames.MOUSE_STATUS] & 1) == 0) { // no human? _numObjs = 0; return; // no human, so we don't want the mouse engine } if (Logic.ScriptVars[(int)ScriptVariableNames.TOP_MENU_DISABLED] == 0) { if (y < 40) { // okay, we are in the top menu. if (!_inTopMenu) { // are we just entering it? if (Logic.ScriptVars[(int)ScriptVariableNames.OBJECT_HELD] == 0) { _menu.FnStartMenu(); } SetPointer(SwordRes.MSE_POINTER, 0); } _menu.CheckTopMenu(); _inTopMenu = true; } else if (_inTopMenu) { // we're not in the menu. did we just leave it? if (Logic.ScriptVars[(int)ScriptVariableNames.OBJECT_HELD] == 0) { _menu.FnEndMenu(); } _inTopMenu = false; } } else if (_inTopMenu) { _menu.FnEndMenu(); _inTopMenu = false; } Logic.ScriptVars[(int)ScriptVariableNames.MOUSE_X] = Logic.ScriptVars[(int)ScriptVariableNames.SCROLL_OFFSET_X] + x + 128; Logic.ScriptVars[(int)ScriptVariableNames.MOUSE_Y] = Logic.ScriptVars[(int)ScriptVariableNames.SCROLL_OFFSET_Y] + y + 128 - 40; //- int touchedId = 0; ushort clicked = 0; if (y > 40) { for (ushort priority = 0; (priority < 10) && (touchedId == 0); priority++) { for (ushort cnt = 0; (cnt < _numObjs) && (touchedId == 0); cnt++) { if ((_objList[cnt].compact.priority == priority) && (Logic.ScriptVars[(int)ScriptVariableNames.MOUSE_X] >= (uint)_objList[cnt].compact.mouse_x1) && (Logic.ScriptVars[(int)ScriptVariableNames.MOUSE_X] <= (uint)_objList[cnt].compact.mouse_x2) && (Logic.ScriptVars[(int)ScriptVariableNames.MOUSE_Y] >= (uint)_objList[cnt].compact.mouse_y1) && (Logic.ScriptVars[(int)ScriptVariableNames.MOUSE_Y] <= (uint)_objList[cnt].compact.mouse_y2)) { touchedId = _objList[cnt].id; clicked = cnt; } } } if (touchedId != (int)Logic.ScriptVars[(int)ScriptVariableNames.SPECIAL_ITEM]) { //the mouse collision situation has changed in one way or another Logic.ScriptVars[(int)ScriptVariableNames.SPECIAL_ITEM] = (uint)touchedId; if (_getOff != 0) { // there was something else selected before, run its get-off script _logic.RunMouseScript(null, (int)_getOff); _getOff = 0; } if (touchedId != 0) { // there's something new selected, now. if (_objList[clicked].compact.mouse_on != 0) //run its get on { _logic.RunMouseScript(_objList[clicked].compact, _objList[clicked].compact.mouse_on); } _getOff = (uint)_objList[clicked].compact.mouse_off; //setup get-off for later } } } else { Logic.ScriptVars[(int)ScriptVariableNames.SPECIAL_ITEM] = 0; } if ((_state & MOUSE_DOWN_MASK) != 0) { if (_inTopMenu) { if (Logic.ScriptVars[(int)ScriptVariableNames.SECOND_ITEM] != 0) { _logic.RunMouseScript(null, (int)Menu._objectDefs[Logic.ScriptVars[(int)ScriptVariableNames.SECOND_ITEM], MenuObject.useScript]); } if (Logic.ScriptVars[(int)ScriptVariableNames.MENU_LOOKING] != 0) { _logic.CfnPresetScript(null, -1, Logic.PLAYER, Logic.SCR_menu_look, 0, 0, 0, 0); } } Logic.ScriptVars[(int)ScriptVariableNames.MOUSE_BUTTON] = (uint)(_state & MOUSE_DOWN_MASK); if (Logic.ScriptVars[(int)ScriptVariableNames.SPECIAL_ITEM] != 0) { SwordObject compact = _objMan.FetchObject(Logic.ScriptVars[(int)ScriptVariableNames.SPECIAL_ITEM]); _logic.RunMouseScript(compact, compact.mouse_click); } } _numObjs = 0; }