diff options
author | lordjaxom <lordjaxom> | 2004-12-21 18:35:54 +0000 |
---|---|---|
committer | lordjaxom <lordjaxom> | 2004-12-21 18:35:54 +0000 |
commit | c05277882c111760d4e275b8521bb057e913a946 (patch) | |
tree | 4eafb4a11134d83b3a5f0d6658fa3df9f924d26f | |
parent | de783ac67265a5a11ebbad52e8dbc81292b4ac66 (diff) | |
download | vdr-plugin-text2skin-c05277882c111760d4e275b8521bb057e913a946.tar.gz vdr-plugin-text2skin-c05277882c111760d4e275b8521bb057e913a946.tar.bz2 |
- dunno
-rw-r--r-- | common.c | 24 | ||||
-rw-r--r-- | common.h | 6 | ||||
-rw-r--r-- | display.c | 7 | ||||
-rw-r--r-- | render.c | 20 | ||||
-rw-r--r-- | render.h | 6 | ||||
-rw-r--r-- | status.c | 105 | ||||
-rw-r--r-- | status.h | 30 | ||||
-rw-r--r-- | xml/function.c | 3 | ||||
-rw-r--r-- | xml/skin.c | 6 | ||||
-rw-r--r-- | xml/skin.h | 6 | ||||
-rw-r--r-- | xml/string.c | 11 | ||||
-rw-r--r-- | xml/string.h | 4 | ||||
-rw-r--r-- | xml/type.h | 18 |
13 files changed, 194 insertions, 52 deletions
@@ -1,5 +1,5 @@ /* - * $Id: common.c,v 1.1 2004/12/19 22:03:09 lordjaxom Exp $ + * $Id: common.c,v 1.2 2004/12/21 18:35:54 lordjaxom Exp $ */ #include "common.h" @@ -89,6 +89,28 @@ const char *ChannelBouquet(const cChannel *Channel, int Number) { #endif } */ + +bool StoppedTimer(const char *Name) +{ + cTimer *timer = Timers.First(); + while (timer) { + if (strcmp(Name, timer->File()) == 0) + break; + timer = Timers.Next(timer); + } + return timer == NULL || !timer->Recording(); +} + +const cRecording *GetRecordingByName(const char *Name) +{ + const cRecording *rec = Recordings.First(); + for (; rec != NULL; rec = Recordings.Next(rec)) { + if (strcmp(rec->Name(), Name) == 0) + return rec; + } + return NULL; +} + cxType TimeType(time_t Time, const std::string &Format) { static char result[1000]; @@ -1,5 +1,5 @@ /* - * $Id: common.h,v 1.1 2004/12/19 22:03:09 lordjaxom Exp $ + * $Id: common.h,v 1.2 2004/12/21 18:35:54 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_COMMON_H @@ -26,6 +26,7 @@ class cMarks; class cChannel; +class cRecording; // helper functions @@ -35,6 +36,9 @@ const char *ChannelName(const cChannel *Channel, int Number); const char *ChannelShortName(const cChannel *Channel, int Number); //const char *ChannelBouquet(const cChannel *Channel, int Number); +bool StoppedTimer(const char *Name); +const cRecording *GetRecordingByName(const char *Name); + cxType TimeType(time_t Time, const std::string &Format); cxType DurationType(uint Index, const std::string &Format); @@ -1,5 +1,5 @@ /* - * $Id: display.c,v 1.1 2004/12/19 22:03:12 lordjaxom Exp $ + * $Id: display.c,v 1.2 2004/12/21 18:35:54 lordjaxom Exp $ */ #include "render.h" @@ -549,9 +549,6 @@ cxType cText2SkinDisplayReplay::GetTokenData(const txToken &Token) ? (cxType)mText : (cxType)false; - case tReplayMode: - return cText2SkinStatus::ReplayMode(); - case tButtonRed: return mButtonRed; @@ -723,8 +720,6 @@ void cText2SkinDisplayMenu::SetItem(const char *Text, int Index, bool Current, b return; tListItem *item = new tListItem(Text, Selectable); - //item.text = Text; - //item.sel = Selectable; for (int i = 0; i < MaxTabs; ++i) { const char *tab = GetTabbedText(Text, i); @@ -1,5 +1,5 @@ /* - * $Id: render.c,v 1.1 2004/12/19 22:03:16 lordjaxom Exp $ + * $Id: render.c,v 1.2 2004/12/21 18:35:54 lordjaxom Exp $ */ #include "render.h" @@ -36,6 +36,7 @@ cText2SkinRender::cText2SkinRender(cText2SkinLoader *Loader, cxDisplay::eType Di mBaseSize() { mRender = this; + Text2SkinStatus.SetRender(this); SetDescription("Text2Skin: %s display update", mDisplay->GetType().c_str()); @@ -49,6 +50,7 @@ cText2SkinRender::cText2SkinRender(cText2SkinLoader *Loader, cxDisplay::eType Di if (!mScreen->IsOpen()) return; + mSkin->SetBase(); // refresh base coords in case the setup changed mBaseSize = mSkin->BaseSize(); eOsdError res; @@ -108,8 +110,8 @@ cText2SkinRender::~cText2SkinRender() delete mScroller; mMarquees.clear(); delete mScreen; - //cText2SkinBitmap::ResetCache(); mRender = NULL; + Text2SkinStatus.SetRender(NULL); } void cText2SkinRender::Action(void) @@ -474,8 +476,12 @@ cxType cText2SkinRender::GetToken(const txToken &Token) if (Token.Type == tMenuCurrent) { const char *ptr = str.c_str(); char *end; - strtoul(ptr, &end, 10); - res = skipspace(end); + int n = strtoul(ptr, &end, 10); + if (n != 0) + res = skipspace(end); + else + res = ptr; + Dprintf("MenuCurrent result: |%s|\n", res.String().c_str()); } else if (Token.Type == tMenuTitle) { if ((pos = str.find(" - ")) != -1 @@ -488,7 +494,9 @@ cxType cText2SkinRender::GetToken(const txToken &Token) Dprintf("MenuTitle result: |%s|\n", res.String().c_str()); } } - return (mRender->mTokenCache[Token] = res); + if (!res.NoCache()) + mRender->mTokenCache[Token] = res; + return res; } return cxType::False; } @@ -506,5 +514,5 @@ cxType cText2SkinRender::GetTokenData(const txToken &Token) default: break; } - return cxType::False; + return Text2SkinStatus.GetTokenData(Token); } @@ -1,5 +1,5 @@ /* - * $Id: render.h,v 1.2 2004/12/21 14:55:39 lordjaxom Exp $ + * $Id: render.h,v 1.3 2004/12/21 18:35:54 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_RENDER_H @@ -28,8 +28,10 @@ class cText2SkinRender: public cThread { friend class cText2SkinDisplayMessage; friend class cText2SkinDisplayMenu; + friend class cText2SkinStatus; + /* Skin Editor */ - //friend class VSkinnerScreen; + friend class VSkinnerScreen; private: typedef std::map<txToken,cxType> tTokenCache; @@ -1,23 +1,42 @@ /* - * $Id: status.c,v 1.1 2004/12/19 22:03:19 lordjaxom Exp $ + * $Id: status.c,v 1.2 2004/12/21 18:35:54 lordjaxom Exp $ */ #include "status.h" +#include "render.h" -cText2SkinStatus *cText2SkinStatus::mStatus = NULL; -const std::string cText2SkinStatus::ReplayNames[__REPLAY_COUNT__] = +const std::string ReplayNames[__REPLAY_COUNT__] = { "", "normal", "mp3", "mplayer", "dvd", "vcd", "image" }; +cText2SkinStatus *cText2SkinStatus::mStatus = NULL; cText2SkinStatus Text2SkinStatus; -cText2SkinStatus::cText2SkinStatus(void) { +cText2SkinStatus::cText2SkinStatus(void): + mRender(NULL), + mReplayMode(replayNone), + mRecordings(), + mCurrentRecording(0), + mNextRecording(0) +{ mStatus = this; - mReplayMode = replayNone; +} + +void cText2SkinStatus::SetRender(cText2SkinRender *Render) +{ + mRender = Render; + mCurrentRecording = 0; + mNextRecording = 0; } void cText2SkinStatus::Replaying(const cControl* /*Control*/, const char *Name) { + Dprintf("cText2SkinStatus::Replaying(%s)\n", Name); + eReplayMode oldMode = mReplayMode; + + if (mRender != NULL) + mRender->UpdateLock(); + if (Name != NULL) { - mReplayMode = replayNormal; + mReplayMode = replayMPlayer; if (strlen(Name) > 6 && Name[0]=='[' && Name[3]==']' && Name[5]=='(') { int i; for (i = 6; Name[i]; ++i) { @@ -26,7 +45,10 @@ void cText2SkinStatus::Replaying(const cControl* /*Control*/, const char *Name) } if (Name[i]) // replaying mp3 mReplayMode = replayMP3; - } else if (strcmp(Name, "DVD") == 0) + } + else if (GetRecordingByName(Name) != NULL) + mReplayMode = replayNormal; + else if (strcmp(Name, "DVD") == 0) mReplayMode = replayDVD; else if (strcmp(Name, "VCD") == 0) mReplayMode = replayVCD; @@ -46,4 +68,73 @@ void cText2SkinStatus::Replaying(const cControl* /*Control*/, const char *Name) } } else mReplayMode = replayNone; + + if (mRender != NULL) { + if (mReplayMode != oldMode) + mRender->SetDirty(); + mRender->UpdateUnlock(); + } +} + +void cText2SkinStatus::Recording(const cDevice *Device, const char *Name) +{ + if (mRender != NULL) + mRender->UpdateLock(); + + if (Name != NULL) { + tRecordingInfo info(Name, Device); + mRecordings.push_back(info); + } else { + tRecordings::iterator it = mRecordings.begin(); + for (; it != mRecordings.end(); ++it) { + if ((*it).device == Device && StoppedTimer((*it).name.c_str())) { + mRecordings.erase(it); + break; + } + } + } + + if (mRender != NULL) { + mRender->UpdateUnlock(); + mRender->Flush(true); + } +} + +cxType cText2SkinStatus::GetTokenData(const txToken &Token) +{ + switch (Token.Type) { + case tReplayMode: + return ReplayNames[mReplayMode]; + + case tCurrentRecording: + if (Token.Attrib.Type == aNumber) { + return mRecordings.size() > (uint)Token.Attrib.Number + ? (cxType)mRecordings[Token.Attrib.Number].name + : (cxType)false; + } else if (mRecordings.size() > 0) { + uint now = time_ms(); + if (mNextRecording == 0) + mNextRecording = now + 2000; + else if (now >= mNextRecording) { + mCurrentRecording = (mCurrentRecording + 1) % mRecordings.size(); + mNextRecording = now + 2000; + } + + uint next = 0; + if (mRecordings.size() > 1) { + next = mNextRecording - now; + Dprintf("next update in %d ms\n", next); + } + + cxType res = mRecordings[mCurrentRecording].name; + res.SetNoCache(); + return res; + } + return false; + + default: + break; + }; + + return cxType::False; } @@ -1,5 +1,5 @@ /* - * $Id: status.h,v 1.1 2004/12/19 22:03:19 lordjaxom Exp $ + * $Id: status.h,v 1.2 2004/12/21 18:35:54 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_STATUS_H @@ -8,6 +8,8 @@ #include "common.h" #include <vdr/status.h> +class cText2SkinRender; + class cText2SkinStatus: public cStatus { public: enum eReplayMode { @@ -19,26 +21,38 @@ public: replayVCD, replayImage, -#define __REPLAY_COUNT__ (replayImage+1) +#define __REPLAY_COUNT__ (cText2SkinStatus::replayImage+1) }; + struct tRecordingInfo { + std::string name; + const cDevice *device; + + tRecordingInfo(const std::string &n, const cDevice *d): name(n), device(d) {} + }; + typedef std::vector<tRecordingInfo> tRecordings; + private: static cText2SkinStatus *mStatus; - static const std::string ReplayNames[__REPLAY_COUNT__]; - eReplayMode mReplayMode; + cText2SkinRender *mRender; + eReplayMode mReplayMode; + tRecordings mRecordings; + uint mCurrentRecording; + uint mNextRecording; protected: virtual void Replaying(const cControl *Control, const char *Name); + virtual void Recording(const cDevice *Device, const char *Name); public: cText2SkinStatus(void); - static const std::string &ReplayMode(void); + void SetRender(cText2SkinRender *Render); + + cxType GetTokenData(const txToken &Token); }; -inline const std::string &cText2SkinStatus::ReplayMode(void) { - return ReplayNames[mStatus->mReplayMode]; -} +extern cText2SkinStatus Text2SkinStatus; #endif // VDR_TEXT2SKIN_STATUS_H diff --git a/xml/function.c b/xml/function.c index ca06922..04a3f2f 100644 --- a/xml/function.c +++ b/xml/function.c @@ -1,5 +1,5 @@ /* - * $Id: function.c,v 1.1 2004/12/19 22:03:26 lordjaxom Exp $ + * $Id: function.c,v 1.2 2004/12/21 18:35:54 lordjaxom Exp $ */ #include "xml/function.h" @@ -204,6 +204,7 @@ std::string cxFunction::Evaluate(void) const return FunFile(mParams[0]->Evaluate()); case fun_trans: + Dprintf("|%s| translates to |%s|\n", mParams[0]->Evaluate().c_str(), tr(mParams[0]->Evaluate().c_str())); return tr(mParams[0]->Evaluate().c_str()); case fun_plugin: @@ -1,5 +1,5 @@ /* - * $Id: skin.c,v 1.1 2004/12/19 22:03:28 lordjaxom Exp $ + * $Id: skin.c,v 1.2 2004/12/21 18:35:54 lordjaxom Exp $ */ #include "xml/skin.h" @@ -13,7 +13,9 @@ cxSkin::cxSkin(const std::string &Name): } void cxSkin::SetBase(eScreenBase Base) { - mBase = Base; + if (Base != (eScreenBase)-1) + mBase = Base; + switch (mBase) { case relative: mBaseOffset = txPoint(Setup.OSDLeft, Setup.OSDTop); @@ -1,5 +1,5 @@ /* - * $Id: skin.h,v 1.1 2004/12/19 22:03:28 lordjaxom Exp $ + * $Id: skin.h,v 1.2 2004/12/21 18:35:55 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_XML_SKIN_H @@ -37,15 +37,13 @@ private: cxDisplays mDisplays; -protected: - void SetBase(eScreenBase Base); - public: cxSkin(const std::string &Name); cxDisplay *Get(cxDisplay::eType Type); bool ParseBase(const std::string &Text); + void SetBase(eScreenBase Base = (eScreenBase)-1); eScreenBase Base(void) const { return mBase; } const txPoint &BaseOffset(void) const { return mBaseOffset; } diff --git a/xml/string.c b/xml/string.c index 742439e..5d6b397 100644 --- a/xml/string.c +++ b/xml/string.c @@ -1,5 +1,5 @@ /* - * $Id: string.c,v 1.1 2004/12/19 22:03:25 lordjaxom Exp $ + * $Id: string.c,v 1.2 2004/12/21 18:35:55 lordjaxom Exp $ */ #include "xml/string.h" @@ -11,14 +11,13 @@ static const char *Tokens[__COUNT_TOKEN__] = { // Channel Display "ChannelNumber", "ChannelName", "ChannelShortName", "ChannelBouquet", "ChannelPortal", - "ChannelSource", "PresentStartDateTime", - "PresentVPSDateTime", "PresentEndDateTime", "PresentDuration", "PresentProgress", - "PresentRemaining", + "ChannelSource", "PresentStartDateTime", "PresentVPSDateTime", "PresentEndDateTime", + "PresentDuration", "PresentProgress", "PresentRemaining", "PresentTitle", "PresentShortText", "PresentDescription", "FollowingStartDateTime", "FollowingVPSDateTime", "FollowingEndDateTime", "FollowingDuration", "FollowingTitle", "FollowingShortText", "FollowingDescription", "Language", - "HasTeletext", "HasMultilang", "HasDolby", "IsEncrypted", "IsRadio", "IsRecording", "HasVPS", - "HasTimer", "IsRunning", + "HasTeletext", "HasMultilang", "HasDolby", "IsEncrypted", "IsRadio", "IsRecording", + "CurrentRecording", "HasVPS", "HasTimer", "IsRunning", // Volume Display "VolumeCurrent", "VolumeTotal", "IsMute", diff --git a/xml/string.h b/xml/string.h index 00e5fab..e53bafb 100644 --- a/xml/string.h +++ b/xml/string.h @@ -1,5 +1,5 @@ /* - * $Id: string.h,v 1.1 2004/12/19 22:03:28 lordjaxom Exp $ + * $Id: string.h,v 1.2 2004/12/21 18:35:55 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_XML_STRING_H @@ -43,6 +43,8 @@ enum exToken { tIsEncrypted, tIsRadio, tIsRecording, + // next 1 also in all other displays + tCurrentRecording, // next 3 also in Menu tHasVPS, tHasTimer, @@ -1,5 +1,5 @@ /* - * $Id: type.h,v 1.1 2004/12/19 22:03:28 lordjaxom Exp $ + * $Id: type.h,v 1.2 2004/12/21 18:35:55 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_XML_TYPE_H @@ -20,21 +20,25 @@ private: eType mType; std::string mString; int mNumber; + bool mNoCache; public: static cxType True; static cxType False; - cxType(void): mType(boolean), mNumber(0) {} - cxType(const char *String): mType(string), mString(String ?: "") {} - cxType(std::string String): mType(string), mString(String) {} - cxType(int Number): mType(number), mNumber(Number) {} - cxType(time_t Number): mType(number), mNumber(Number) {} - cxType(bool Value): mType(boolean), mNumber(Value ? 1 : 0) {} + cxType(void): mType(boolean), mNumber(0), mNoCache(false) {} + cxType(const char *String): mType(string), mString(String ?: ""), mNoCache(false) {} + cxType(std::string String): mType(string), mString(String), mNoCache(false) {} + cxType(int Number): mType(number), mNumber(Number), mNoCache(false) {} + cxType(time_t Number): mType(number), mNumber(Number), mNoCache(false) {} + cxType(bool Value): mType(boolean), mNumber(Value ? 1 : 0), mNoCache(false) {} const std::string &String(void); int Number(void) const { return mType == number ? mNumber : 0; } + void SetNoCache(bool Enable = true) { mNoCache = Enable; } + bool NoCache(void) const { return mNoCache; } + operator std::string () { return String(); } operator int () { return Number(); } operator bool () { return Number(); } |