protected int m_nLastId; // Highest numbered ingredient. Used to make new ids for clones. public MHGroup() { m_Items = new MHSequence <MHIngredient>(); m_StartUp = new MHActionSequence(); m_CloseDown = new MHActionSequence(); m_Timers = new List <MHTimer>(); }
public MHTokenGroup() { m_MovementTable = new MHSequence <MHMovement>(); m_TokenGrpItems = new MHSequence <MHTokenGroupItem>(); m_NoTokenActionSlots = new MHSequence <MHActionSequence>(); m_nTokenPosition = 1; }
public virtual void SI_GetBasicSI(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { // Returns basic SI information about the service indicated by an index // returned by GSI. // Returns networkID, origNetworkID, transportStreamID, serviceID Logging.Assert(false); }
private MHSequence <MHParameter> m_Parameters; // Arguments. public MHCall(string name, bool bIsFork) : base(name) { m_Succeeded = new MHObjectRef(); m_Parameters = new MHSequence <MHParameter>(); m_bIsFork = bIsFork; }
public MHPersistent(string name, bool bIsLoad) : base(name) { m_bIsLoad = bIsLoad; m_Succeeded = new MHObjectRef(); m_Variables = new MHSequence <MHObjectRef>(); m_FileName = new MHGenericOctetString(); }
public virtual void SearchAndExtractSubString(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { if (args.Size == 5) { // Find a substring within a string and return an index to the position // and the prefix to the substring. MHOctetString str = new MHOctetString(); MHOctetString searchString = new MHOctetString(); GetString(args.GetAt(0), str, engine); int nStart = GetInt(args.GetAt(1), engine); if (nStart < 1) { nStart = 1; } GetString(args.GetAt(2), searchString, engine); // Strings are indexed from one. int nPos; for (nPos = nStart - 1; nPos <= str.Size - searchString.Size; nPos++) { int i; for (i = 0; i < searchString.Size; i++) { if (searchString.GetAt(i) != str.GetAt(i + nPos)) { break; // Doesn't match } } if (i == searchString.Size) { break; // Found a match. } } // Set the results. MHParameter pResString = args.GetAt(3); MHParameter pResInt = args.GetAt(4); SetSuccessFlag(success, true, engine); // Set this first. if (nPos <= str.Size - searchString.Size) { // Found // Set the index to the position AFTER the string, counting from 1. engine.FindObject(pResInt.GetReference()).SetVariableValue(new MHUnion(nPos + 1 + searchString.Size)); // Return the sequence from nStart - 1 of length nPos - nStart + 1 MHOctetString resultString = new MHOctetString(str, nStart - 1, nPos - nStart + 1); engine.FindObject(pResString.GetReference()).SetVariableValue(new MHUnion(resultString)); } else { // Not found. Set the result string to empty and the result index to -1 engine.FindObject(pResInt.GetReference()).SetVariableValue(new MHUnion(-1)); engine.FindObject(pResString.GetReference()).SetVariableValue(new MHUnion(new MHOctetString(""))); } } else { SetSuccessFlag(success, false, engine); } }
public MHListGroup() { m_Positions = new MHSequence <Point>(); m_ItemList = new List <MHListItem>(); m_fWrapAround = false; m_fMultipleSelection = false; m_nFirstItem = 1; m_nLastFirstItem = m_nFirstItem; m_nLastCount = 0; }
public virtual void SI_TuneIndex(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { // Tunes to an index returned by GSI if (args.Size == 1) { int nChannel = GetInt(args.GetAt(0), engine); bool res = engine.GetContext().TuneTo(nChannel); SetSuccessFlag(success, res, engine); } else { SetSuccessFlag(success, false, engine); } }
public virtual void SearchSubString(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { if (args.Size == 4) { // Find a substring within a string and return an index to the position. MHOctetString str = new MHOctetString(); MHOctetString searchString = new MHOctetString(); GetString(args.GetAt(0), str, engine); int nStart = GetInt(args.GetAt(1), engine); if (nStart < 1) { nStart = 1; } GetString(args.GetAt(2), searchString, engine); // Strings are indexed from one. int nPos; for (nPos = nStart - 1; nPos <= str.Size - searchString.Size; nPos++) { int i; for (i = 0; i < searchString.Size; i++) { if (searchString.GetAt(i) != str.GetAt(i + nPos)) { break; } } if (i == searchString.Size) { break; // Found a match. } } // Set the result. MHParameter pResInt = args.GetAt(3); SetSuccessFlag(success, true, engine); // Set this first. if (nPos <= str.Size - searchString.Size) { // Found // Set the index to the position of the string, counting from 1. engine.FindObject(pResInt.GetReference()).SetVariableValue(new MHUnion(nPos + 1)); } else { // Not found. Set the result index to -1 engine.FindObject(pResInt.GetReference()).SetVariableValue(new MHUnion(-1)); } } else { SetSuccessFlag(success, false, engine); } }
public virtual void Random(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { if (args.Size == 2) { int nLimit = GetInt(args.GetAt(0), engine); MHParameter pResInt = args.GetAt(1); Random randomGenerator = new Random(); engine.FindObject((pResInt.GetReference())).SetVariableValue(new MHUnion(randomGenerator.Next(nLimit) + 1)); SetSuccessFlag(success, true, engine); } else { SetSuccessFlag(success, false, engine); } }
public virtual void GetStringLength(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { if (args.Size == 2) { // Find a substring within a string and return an index to the position. MHOctetString str = new MHOctetString(); GetString(args.GetAt(0), str, engine); MHParameter pResInt = args.GetAt(1); SetSuccessFlag(success, true, engine); engine.FindObject(pResInt.GetReference()).SetVariableValue(new MHUnion(str.Size)); } else { SetSuccessFlag(success, false, engine); } }
public virtual void CastToObjectRef(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { // Converts a string and an integer to an ObjectRef. if (args.Size == 3) { MHObjectRef result = new MHObjectRef(); GetString(args.GetAt(0), result.GroupId, engine); result.ObjectNo = GetInt(args.GetAt(1), engine); engine.FindObject(args.GetAt(2).GetReference()).SetVariableValue(new MHUnion(result)); SetSuccessFlag(success, true, engine); } else { SetSuccessFlag(success, false, engine); } }
public virtual void GetDayOfWeek(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { if (args.Size == 2) { int date = GetInt(args.GetAt(0), engine); // Date as produced in GCD DateTime dt = new DateTime(1858, 11, 17); int nDayOfWeek = (int)dt.AddDays(date).DayOfWeek; engine.FindObject(args.GetAt(1).GetReference()).SetVariableValue(new MHUnion(nDayOfWeek)); SetSuccessFlag(success, true, engine); } else { SetSuccessFlag(success, false, engine); } }
public virtual void CastToContentRef(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { // Converts a string to a ContentRef. if (args.Size == 2) { MHOctetString str = new MHOctetString(); GetString(args.GetAt(0), str, engine); MHContentRef result = new MHContentRef(); result.ContentRef.Copy(str); engine.FindObject(args.GetAt(1).GetReference()).SetVariableValue(new MHUnion(result)); SetSuccessFlag(success, true, engine); } else { SetSuccessFlag(success, false, engine); } }
public virtual void GetCurrentDate(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { if (args.Size == 2) { DateTime dt = new DateTime(1858, 11, 17); DateTime now = DateTime.Now; int nModJulianDate = now.Subtract(dt).Days; int nTimeAsSecs = (int)now.TimeOfDay.TotalSeconds; engine.FindObject(args.GetAt(0).GetReference()).SetVariableValue(new MHUnion(nModJulianDate)); engine.FindObject(args.GetAt(1).GetReference()).SetVariableValue(new MHUnion(nTimeAsSecs)); SetSuccessFlag(success, true, engine); } else { SetSuccessFlag(success, false, engine); } }
public virtual void SI_GetServiceIndex(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { // Returns an index indicating the service if (args.Size == 2) { MHOctetString str = new MHOctetString(); GetString(args.GetAt(0), str, engine); MHParameter pResInt = args.GetAt(1); // The format of the service is dvb://netID.[transPortID].serviceID // where the IDs are in hex. // or rec://svc/lcn/N where N is the "logical channel number" i.e. the Freeview channel. int nResult = engine.GetContext().GetChannelIndex(str.ToString()); engine.FindObject(pResInt.GetReference()).SetVariableValue(new MHUnion(nResult)); Logging.Log(Logging.MHLogDetail, "Get service index for " + str.Printable() + " - result " + nResult); SetSuccessFlag(success, true, engine); } else { SetSuccessFlag(success, false, engine); } }
public virtual void WhoAmI(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { // Return a concatenation of the strings we respond to in // GetEngineSupport(UKEngineProfile(X)) if (args.Size == 1) { MHOctetString result = new MHOctetString(); result.Copy(MHEngine.MHEGEngineProviderIdString); result.Append(" "); result.Append(engine.GetContext().GetReceiverId()); result.Append(" "); result.Append(engine.GetContext().GetDSMCCId()); engine.FindObject((args.GetAt(0).GetReference())).SetVariableValue(new MHUnion(result)); SetSuccessFlag(success, true, engine); } else { SetSuccessFlag(success, false, engine); } }
public virtual void GetSubString(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { if (args.Size == 4) { // Extract a sub-string from a string. MHOctetString str = new MHOctetString(); GetString(args.GetAt(0), str, engine); int nBeginExtract = GetInt(args.GetAt(1), engine); int nEndExtract = GetInt(args.GetAt(2), engine); if (nBeginExtract < 1) { nBeginExtract = 1; } if (nBeginExtract > str.Size) { nBeginExtract = str.Size; } if (nEndExtract < 1) { nEndExtract = 1; } if (nEndExtract > str.Size) { nEndExtract = str.Size; } MHParameter pResString = args.GetAt(3); // Returns beginExtract to endExtract inclusive. engine.FindObject(pResString.GetReference()).SetVariableValue( new MHUnion(new MHOctetString(str, nBeginExtract - 1, nEndExtract - nBeginExtract + 1))); SetSuccessFlag(success, true, engine); } else { SetSuccessFlag(success, false, engine); } }
protected string m_Path; // Path from the root directory to this application. Either the null string or // a string of the form /a/b/c . public MHApplication() { m_fIsApp = true; m_nCharSet = 0; m_nTextCHook = 0; m_nIPCHook = 0; m_nStrCHook = 0; m_nBitmapCHook = 0; m_nLineArtCHook = 0; m_pCurrentScene = null; m_nLockCount = 0; m_fRestarting = false; m_OnSpawnCloseDown = new MHActionSequence(); m_OnRestart = new MHActionSequence(); m_BGColour = new MHColour(); m_TextColour = new MHColour(); m_ButtonRefColour = new MHColour(); m_HighlightRefColour = new MHColour(); m_SliderRefColour = new MHColour(); m_Font = new MHFontBody(); m_FontAttrs = new MHOctetString(); m_DisplayStack = new MHSequence <MHVisible>(); }
// UK MHEG specifies the use of the Tiresias font and broadcasters appear to // assume that all MHEG applications will lay the text out in the same way. // Recreate the image. protected void Redraw() { if (!RunningStatus || m_pDisplay == null) { return; } if (m_nBoxWidth == 0 || m_nBoxHeight == 0) { return; // Can't draw zero sized boxes. } m_pDisplay.SetSize(m_nBoxWidth, m_nBoxHeight); m_pDisplay.Clear(); MHRgba textColour = GetColour(m_textColour); // Process any escapes in the text and construct the text arrays. MHSequence <MHTextLine> theText = new MHSequence <MHTextLine>(); // Set up the first item on the first line. MHTextItem pCurrItem = new MHTextItem(); MHTextLine pCurrLine = new MHTextLine(); pCurrLine.Items.Append(pCurrItem); theText.Append(pCurrLine); Stack <MHRgba> m_ColourStack = new Stack <MHRgba>(); // Stack to handle nested colour codes. m_ColourStack.Push(textColour); pCurrItem.Colour = textColour; int i = 0; while (i < m_Content.Size) { char ch = m_Content.GetAt(i++); if (ch == '\t') // Tab - start a new item if we have any text in the existing one. { if (pCurrItem.Text.Size != 0) { pCurrItem = pCurrItem.NewItem(); pCurrLine.Items.Append(pCurrItem); } pCurrItem.TabCount++; } else if (ch == '\r') // CR - line break. // TODO: Two CRs next to one another are treated as </P> rather than <BR><BR> // This should also include the sequence CRLFCRLF. { pCurrLine = new MHTextLine(); theText.Append(pCurrLine); pCurrItem = pCurrItem.NewItem(); pCurrLine.Items.Append(pCurrItem); } else if (ch == 0x1b) // Escape - special codes. { if (i == m_Content.Size) { break; } char code = m_Content.GetAt(i); // The only codes we are interested in are the start and end of colour. // TODO: We may also need "bold" and some hypertext colours. if (code >= 0x40 && code <= 0x5e) // Start code // Start codes are followed by a parameter count and a number of parameter bytes. { if (++i == m_Content.Size) { break; } char paramCount = m_Content.GetAt(i); i++; if (code == 0x43 && paramCount == 4 && i + paramCount <= m_Content.Size) { // Start of colour. if (pCurrItem.Text.Size != 0) { pCurrItem = pCurrItem.NewItem(); pCurrLine.Items.Append(pCurrItem); } pCurrItem.Colour = new MHRgba(m_Content.GetAt(i), m_Content.GetAt(i + 1), m_Content.GetAt(i + 2), 255 - m_Content.GetAt(i + 3)); // Push this colour onto the colour stack. m_ColourStack.Push(pCurrItem.Colour); } else { Logging.Log(Logging.MHLogWarning, "Unknown text escape code " + code); } i += paramCount; // Skip the parameters } else if (code >= 0x60 && code <= 0x7e) // End code. { i++; if (code == 0x63) { if (m_ColourStack.Count > 1) { m_ColourStack.Pop(); // Start a new item since we're using a new colour. if (pCurrItem.Text.Size != 0) { pCurrItem = pCurrItem.NewItem(); pCurrLine.Items.Append(pCurrItem); } // Set the subsequent text in the colour we're using now. pCurrItem.Colour = m_ColourStack.Peek(); } } } } else if (ch <= 0x1f) { // Certain characters including LF and the marker codes between 0x1c and 0x1f are // explicitly intended to be ignored. Include all the other codes. } else // Add to the current text. { int nStart = i - 1; while (i < m_Content.Size && m_Content.GetAt(i) >= 0x20) { i++; } pCurrItem.Text.Append(new MHOctetString(m_Content, nStart, i - nStart)); } } // Set up the initial attributes. int style, size, lineSpace, letterSpace; InterpretAttributes(m_fontAttrs, out style, out size, out lineSpace, out letterSpace); // Create a font with this information. m_pDisplay.SetFont(size, (style & 2) != 0, (style & 1) != 0); // Calculate the layout of each section. for (i = 0; i < theText.Size; i++) { MHTextLine pLine = theText.GetAt(i); pLine.LineWidth = 0; for (int j = 0; j < pLine.Items.Size; j++) { MHTextItem pItem = pLine.Items.GetAt(j); // Set any tabs. for (int k = 0; k < pItem.TabCount; k++) { pLine.LineWidth += TABSTOP - pLine.LineWidth % TABSTOP; } if (pItem.UnicodeLength == 0) { // Convert UTF-8 to Unicode. int s = pItem.Text.Size; pItem.Unicode = pItem.Text.ToString(); pItem.UnicodeLength = pItem.Unicode.Length; } // Fit the text onto the line. int nFullText = pItem.UnicodeLength; // Get the box size and update pItem.m_nUnicode to the number that will fit. Rectangle rect = m_pDisplay.GetBounds(pItem.Unicode, ref nFullText, m_nBoxWidth - pLine.LineWidth); if (nFullText == pItem.UnicodeLength || !m_fTextWrap) { // All the characters fit or we're not wrapping. pItem.Width = rect.Width; pLine.LineWidth += rect.Width; } /* else if (m_fTextWrap) * { // No, we have to word-wrap. * int nTruncated = pItem.UnicodeLength; // Just in case. * // Now remove characters until we find a word-break character. * while (pItem.UnicodeLength > 0 && pItem.Unicode[pItem.UnicodeLength] != ' ') pItem.UnicodeLength--; * // If there are now word-break characters we truncate the text. * if (pItem.UnicodeLength == 0) pItem.UnicodeLength = nTruncated; * // Special case to avoid infinite loop if the box is very narrow. * if (pItem.UnicodeLength == 0) pItem.UnicodeLength = 1; * * // We need to move the text we've cut off this line into a new line. * int nNewWidth = nFullText - pItem.UnicodeLength; * int nNewStart = pItem.UnicodeLength; * // Remove any spaces at the start of the new section. * while (nNewWidth != 0 && pItem.Unicode[nNewStart] == ' ') { nNewStart++; nNewWidth--; } * if (nNewWidth != 0) { * // Create a new line from the extra text. * MHTextLine pNewLine = new MHTextLine(); * theText.InsertAt(pNewLine, i+1); * // The first item on the new line is the rest of the text. * MHTextItem pNewItem = pItem.NewItem(); * pNewLine.Items.Append(pNewItem); * pNewItem.Unicode = pItem.Unicode.Substring(nNewStart, nNewWidth); * pNewItem.UnicodeLength = nNewWidth; * } * // Remove any spaces at the end of the old section. If we don't do that and * // we are centering or right aligning the text we'll get it wrong. * while (pItem.UnicodeLength > 1 && pItem.Unicode[pItem.UnicodeLength - 1] == ' ') pItem.UnicodeLength--; * int uniLength = pItem.UnicodeLength; * rect = m_pDisplay.GetBounds(pItem.Unicode, ref uniLength, 0); * pItem.Width = rect.Width; * pLine.LineWidth += rect.Width; * } */} } // Now output the text. int yOffset = 0; // If there isn't space for all the lines we should drop extra lines. int nNumLines = theText.Size; do { if (m_VertJ == End) { yOffset = m_nBoxHeight - nNumLines * lineSpace; } else if (m_VertJ == Centre) { yOffset = (m_nBoxHeight - nNumLines * lineSpace) / 2; } if (yOffset < 0) { nNumLines--; } } while (yOffset < 0); for (i = 0; i < nNumLines; i++) { MHTextLine pLine = theText.GetAt(i); int xOffset = 0; if (m_HorizJ == End) { xOffset = m_nBoxWidth - pLine.LineWidth; } else if (m_HorizJ == Centre) { xOffset = (m_nBoxWidth - pLine.LineWidth) / 2; } //ASSERT(xOffset >= 0); for (int j = 0; j < pLine.Items.Size; j++) { MHTextItem pItem = pLine.Items.GetAt(j); // Tab across if necessary. for (int k = 0; k < pItem.TabCount; k++) { xOffset += TABSTOP - xOffset % TABSTOP; } if (pItem.Unicode.Length != 0) // We may have blank lines. { m_pDisplay.AddText(xOffset, yOffset, // Jas removed this cos it doesn't make sense yOffset + lineSpace pItem.Unicode.Substring(0, pItem.UnicodeLength), pItem.Colour); } xOffset += pItem.Width; } yOffset += lineSpace; if (yOffset + lineSpace > m_nBoxHeight) { break; } } }
public MHStream() { m_Multiplex = new MHSequence <MHPresentable>(); m_nStorage = ST_Stream; m_nLooping = 0; // Infinity }
public MHMovement() { m_Movement = new MHSequence <int>(); }
public virtual void Debug(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { Logging.Assert(false); }
public virtual void SetSubtitleMode(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { // Enable or disable subtitles in addition to MHEG. Logging.Assert(false); }
public virtual void CI_SendMessage(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { // Sends a message to a DVB CI application Logging.Assert(false); }
protected MHSequence <MHPointArg> m_Points; // List of points public MHDrawPoly(string name, bool fIsPolygon) : base(name) { m_fIsPolygon = fIsPolygon; m_Points = new MHSequence <MHPointArg>(); }
public virtual void VideoToGraphics(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { // Video to graphics transformation. Logging.Assert(false); }
public virtual void CheckGroupIDRef(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { // Sees if an application or scene with a particular group id // is available in the carousel. Logging.Assert(false); }
public virtual void SetWidescreenAlignment(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { // Sets either LetterBox or Centre-cut-out mode. // Seems to be concerned with aligning a 4:3 scene with an underlying 16:9 video Logging.Assert(false); }
public virtual void GetDisplayAspectRatio(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { // Returns the aspcet ratio. 4:3 => 1, 16:9 => 2 Logging.Assert(false); }