void RichQtfParser::EndPart() { if(istable) { if(paragraph.GetCount() == 0 && text.GetCount() == 0) if(table.GetCount()) table.Top().text.CatPick(pick(tablepart)); else target.CatPick(pick(tablepart)); else { paragraph.part.Clear(); text.Clear(); } } else { Flush(); bool b = paragraph.format.newpage; if(breakpage) paragraph.format.newpage = true; if(table.GetCount()) table.Top().text.Cat(paragraph, target.GetStyles()); else target.Cat(paragraph); paragraph.part.Clear();; paragraph.format.newpage = b; SetFormat(); breakpage = false; } istable = false; }
//задание цвета строки void AnimeList::RowColor(int row) { Date release; Array<CellSeries> array; Date today = GetSysDate(); String xml = listName.Get(row, SeriesRelease); String number, date; int ep = listName.Get(row, Episodes); int ser; if(xml.GetCount() > 0) { int pos; while(xml.GetCount() > 0){ pos = xml.Find("-"); if(pos > 0) { number = String(xml, pos); xml.Remove(0, pos + 1); date = String(xml, 10); xml.Remove(0, 11); series.number = StrInt(number); StrToDate(series.release, date); array.Add(series); } } release = array[array.GetCount()-1].release; if((ep == array[array.GetCount()-1].number) & (today < release)) ser = array[array.GetCount()-1].number - 1; else ser = ((today - release) / 7) + array[array.GetCount()-1].number; } else { release = listName.Get(row, Release); ser = ((today - release) / 7) + 1; } int views = listName.Get(row, Views); if(views == ep) //полностью просмотрено for(int i=0;i<listName.GetColumnCount();i++) listName.SetDisplay(row, i, Single<ColumnBlue>()); else if((views < ep) & (views != 0) & (views == ser)) //нет новых серий, в просмотре for(int i=0;i<listName.GetColumnCount();i++) listName.SetDisplay(row, i, Single<ColumnGreen>()); else if((views < ep) & (views != 0) & (views < ser)) //есть новые серии, в просмотре for(int i=0;i<listName.GetColumnCount();i++) listName.SetDisplay(row, i, Single<ColumnRed>()); else if(views == 0) //нет просмотренных серий for(int i=0;i<listName.GetColumnCount();i++) listName.SetDisplay(row, i, Single<ColumnDefault>()); }
void VFS::Init(const wxString& path) { UnMountAll(); Array<VFSManagerEntry> entries; SaveLoadDevices(entries, true); for(uint i=0; i<entries.GetCount(); ++i) { vfsDevice* dev; switch(entries[i].device) { case vfsDevice_LocalFile: dev = new vfsDeviceLocalFile(); break; case vfsDevice_HDD: dev = new vfsDeviceHDD(entries[i].device_path); break; default: continue; } wxString mpath = entries[i].path; mpath.Replace("$(EmulatorDir)", wxGetCwd()); mpath.Replace("$(GameDir)", vfsDevice::GetRoot(path)); Mount(entries[i].mount, mpath, dev); } }
void RichPara::PackParts(Stream& out, const RichPara::CharFormat& chrstyle, const Array<RichPara::Part>& part, CharFormat& cf, Array<RichObject>& obj) const { for(int i = 0; i < part.GetCount(); i++) { const Part& p = part[i]; Charformat(out, cf, p.format, chrstyle); cf = p.format; if(p.field) { out.Put(FIELD); String s = ~p.field; out % s; s = p.fieldparam; out % s; StringStream oout; CharFormat subf = cf; PackParts(oout, chrstyle, p.fieldpart, subf, obj); s = oout; out % s; } else if(p.object) { obj.Add(p.object); out.Put(OBJECT); } else out.Put(ToUtf8(p.text)); } }
void EnumerateClassesForProvider(Service *provider, const Function<bool (MetaClass *meta, Dictionary *properties)> &callback) { MetaClass *providerClass = provider->GetClass(); spinlock_lock(&_matchingLock); Array *matches = Array::Alloc()->Init(); for(size_t i = 0; i < _registeredClasses->GetCount(); i ++) { ClassEntry *entry = _registeredClasses->GetObjectAtIndex<ClassEntry>(i); if(!entry->IsMatched() && DoShallowMatch(providerClass, entry)) matches->AddObject(entry); } spinlock_unlock(&_matchingLock); for(size_t i = 0; i < matches->GetCount(); i ++) { ClassEntry *entry = matches->GetObjectAtIndex<ClassEntry>(i); if(callback(entry->GetMeta(), entry->GetProperties())) entry->SetMatched(true); } matches->Release(); }
static Rectf SplitPoly(const Array<Pointf>& polygon, const Vector<int>& polyend, bool closed, Array<PolyPart>& parts) { if(polyend.IsEmpty()) return Null; unsigned c = polygon.GetCount(); int n = 1; if(c >= 1 << 16) { c >>= 16; n <<= 8; }
bool CodeEditor::FindLangString(bool back) { int l, h; if(!GetSelection(l, h)) h = GetCursor(); else h = (back ? l : h); h -= GetPos(l = GetLine(h)); for(;;) { Array<IdentPos> list = GetLineIdent(GetUtf8Line(l)); int b, e; if(back) { int i = list.GetCount(); while(--i >= 0 && list[i].begin >= h) ; if(i < 0) { h = 1000000; if(--l < 0) break; continue; } b = GetPos(l, list[i].begin); e = GetPos(l, list[i].end); } else { int i = 0; while(i < list.GetCount() && list[i].end <= h) i++; if(i >= list.GetCount()) { h = 0; if(++l >= GetLineCount()) break; continue; } b = GetPos(l, list[i].begin); e = GetPos(l, list[i].end); } SetSelection(b, e); return true; } return false; }
bool HasItem(const Array<CppItem>& n, const String& m) { if(IsNull(m)) return true; for(int i = 0; i < n.GetCount(); i++) if(n[i].uname.StartsWith(m)) return true; return false; }
bool MatchPm(const Array<CppItem>& n, const String& pm) { if(IsNull(pm)) return true; for(int i = 0; i < n.GetCount(); i++) if(MatchPm(n[i].file, pm)) return true; return false; }
AudioConfig() : m_is_audio_initialized(false) , m_port_in_use(0) , event_key(0) { m_ports.SetCount(8); for (u32 i = 0; i < m_ports.GetCount(); i++) m_ports[i] = nullptr; }
Rect Ctrl::GetWorkArea(Point pt) { Array<Rect> rc; GetWorkArea(rc); for(int i = 0; i < rc.GetCount(); i++) if(rc[i].Contains(pt)) return rc[i]; return GetPrimaryWorkArea(); }
Rect Ctrl::GetVirtualWorkArea() { Rect out = GetPrimaryWorkArea(); Array<Rect> rc; GetWorkArea(rc); for(int i = 0; i < rc.GetCount(); i++) out |= rc[i]; return out; }
String Gather(const Array<OptItem>& set, const Vector<String>& conf, bool nospace) { String s; for(int i = 0; i < set.GetCount(); i++) if(MatchWhen(set[i].when, conf)) { if(!nospace && !s.IsEmpty()) s.Cat(' '); s.Cat(set[i].text); } return s; }
int sys_event_flag_cancel(u32 eflag_id, mem32_t num) { sys_event_flag.Warning("sys_event_flag_cancel(eflag_id=%d, num_addr=0x%x)", eflag_id, num.GetAddr()); EventFlag* ef; if(!sys_event_flag.CheckId(eflag_id, ef)) return CELL_ESRCH; Array<u32> tids; { SMutexLocker lock(ef->m_mutex); tids.SetCount(ef->waiters.GetCount()); for (u32 i = 0; i < ef->waiters.GetCount(); i++) { tids[i] = ef->waiters[i].tid; } ef->waiters.Clear(); } for (u32 i = 0; i < tids.GetCount(); i++) { if (Emu.IsStopped()) break; ef->signal.lock(tids[i]); } if (Emu.IsStopped()) { ConLog.Warning("sys_event_flag_cancel(id=%d) aborted", eflag_id); return CELL_OK; } if (num.IsGood()) { num = tids.GetCount(); return CELL_OK; } if (!num.GetAddr()) { return CELL_OK; } return CELL_EFAULT; }
NAMESPACE_UPP #ifdef PLATFORM_POSIX bool GetBatteryStatus(bool &discharging, int &percentage, int &remainingMin) { /* This is only if acpi package is present StringParse data = Sys("acpi -V"); data.GoAfter("AC Adapter", ":"); String sacStatus = data.GetText(); discharging = sacStatus != "on-line"; data.GoInit(); data.GoAfter("Battery", ":"); data.GoAfter(","); percentage = data.GetInt("%"); data.GoAfter(","); String remaining; if (discharging) { remaining = data.GetText(" "); int hour, min; double secs; StringToHMS(remaining, hour, min, secs); // It is really days:hour:min in this case remainingMin = int(secs) + min*60 + hour*24*60; } else remainingMin = Null; */ percentage = 100; Array<String> files = SearchFile("/proc/acpi/battery", "state"); if (files.GetCount() == 0) return false; StringParse state = LoadFile_Safe(files[0]); if (state == "") return false; bool present; if(!state.GoAfter_Init("present", ":")) return false; present = state.GetText() == "yes"; if (!present) return false; // No battery inserted state.GoAfter_Init("charging state", ":"); discharging = state.GetText() == "discharging"; int presentRate, remainingCapacity; state.GoAfter_Init("present rate", ":"); presentRate = state.GetInt(); state.GoAfter_Init("remaining capacity", ":"); remainingCapacity = state.GetInt(); if (presentRate == 0 || !discharging) remainingMin = Null; else remainingMin = (int)((60.*remainingCapacity)/presentRate); int designCapacity,lastFullCapacity; String vendor, type, model, serial; if (!GetBatteryInfo(present/*, designCapacity, lastFullCapacity, vendor, type, model, serial*/)) percentage = (int)((100.*remainingCapacity)/lastFullCapacity); return true; }
void DlgCompareDir::DoTreeCursor() { String s = GetTreePath(); if(IsNull(s)) return; String fa = AppendFileName(pa, s), fb = AppendFileName(pb, s); String da = LoadFile(fa), db = LoadFile(fb); if(!IsNull(da) || !IsNull(db)) { if(IsNull(da) || IsNull(db)) { qtf.Hide(); lineedit.Show(); lineedit <<= Nvl(db, da); } else { lineedit.Hide(); qtf.Show(); String comptext = "[C2 "; Vector<String> la = GetStringLineMap(da), lb = GetStringLineMap(db); Array<TextSection> sections = CompareLineMaps(la, lb); for(int s = 0; s < sections.GetCount(); s++) { const TextSection& sec = sections[s]; if(sec.same) { comptext << "[@(0.0.0) \1"; if(sec.count1 <= 6) for(int i = 0; i < sec.count1; i++) comptext << ExpandTabs(la[i + sec.start1]) << '\n'; else { for(int i = 0; i < 3; i++) comptext << ExpandTabs(la[i + sec.start1]) << '\n'; comptext << "...\n"; for(int i = -3; i < 0; i++) comptext << ExpandTabs(la[i + sec.start1 + sec.count1]) << '\n'; } comptext << "\1]"; } else { if(sec.count1) { comptext << "[@(0.160.0) \1"; for(int i = 0; i < sec.count1; i++) comptext << ExpandTabs(la[sec.start1 + i]) << '\n'; comptext << "\1]"; } if(sec.count2) { comptext << "[@(0.0.255) \1"; for(int i = 0; i < sec.count2; i++) comptext << ExpandTabs(lb[sec.start2 + i]) << '\n'; comptext << "\1]"; } } } qtf.SetQTF(comptext); } } }
void Clear() { for (u32 i = 0; i < m_ports.GetCount(); i++) { if (m_ports[i]) { delete m_ports[i]; m_ports[i] = nullptr; } } m_port_in_use = 0; }
int sceNpDrmIsAvailable(u32 k_licensee_addr, u32 drm_path_addr) { sceNp.Warning("sceNpDrmIsAvailable(k_licensee_addr=0x%x, drm_path_addr=0x%x)", k_licensee_addr, drm_path_addr); wxString drm_path = fmt::FromUTF8(Memory.ReadString(drm_path_addr)); wxString k_licensee_str; u8 k_licensee[0x10]; for(int i = 0; i < 0x10; i++) { k_licensee[i] = Memory.Read8(k_licensee_addr + i); k_licensee_str += wxString::Format("%02x", k_licensee[i]); } sceNp.Warning("sceNpDrmIsAvailable: Found DRM license file at %s", fmt::ToUTF8(drm_path).c_str()); sceNp.Warning("sceNpDrmIsAvailable: Using k_licensee 0x%s", fmt::ToUTF8(k_licensee_str).c_str()); // Set the necessary file paths. wxString drm_file_name = drm_path.AfterLast('/'); wxString titleID = drm_path.AfterFirst('/').AfterFirst('/').AfterFirst('/').BeforeFirst('/'); wxString enc_drm_path = wxGetCwd() + drm_path; wxString dec_drm_path = wxGetCwd() + "/dev_hdd1/" + titleID + "/" + drm_file_name; wxString rap_dir_path = wxGetCwd() + "/dev_usb000/"; wxString rap_file_path = rap_dir_path; // Search dev_usb000 for a compatible RAP file. vfsDir *raps_dir = new vfsDir(fmt::ToUTF8(rap_dir_path)); if (!raps_dir->IsOpened()) sceNp.Warning("sceNpDrmIsAvailable: Can't find RAP file for DRM!"); else { Array<DirEntryInfo> entries = raps_dir->GetEntries(); for (unsigned int i = 0; i < entries.GetCount(); i++) { if (entries[i].name.find(fmt::ToUTF8(titleID)) != std::string::npos ) { rap_file_path += fmt::FromUTF8(entries[i].name); break; } } } // Create a new directory under dev_hdd1/titleID to hold the decrypted data. wxString tmp_dir = wxGetCwd() + "/dev_hdd1/" + titleID; if (!wxDir::Exists(tmp_dir)) wxMkdir(wxGetCwd() + "/dev_hdd1/" + titleID); // Decrypt this EDAT using the supplied k_licensee and matching RAP file. DecryptEDAT(fmt::ToUTF8(enc_drm_path), fmt::ToUTF8(dec_drm_path), 8, fmt::ToUTF8(rap_file_path), k_licensee, false); return CELL_OK; }
void RichQtfParser::FinishOldTable() { FinishCell(); Index<int> pos; Vector<int> srow; RichTable& t = Table(); Tab& b = table.Top(); for(int i = 0; i < t.GetRows(); i++) { int& s = srow.Add(); s = 0; int nx = b.rown[i]; for(int j = 0; j < nx; j++) s += t.GetSpan(i, j).cx; int xn = 0; for(int j = 0; j < nx; j++) { pos.FindAdd(xn * 10000 / s); xn += t.GetSpan(i, j).cx; } } Vector<int> h = pos.PickKeys(); if(h.GetCount() == 0) Error("table"); Sort(h); pos = pick(h); pos.Add(10000); RichTable tab; tab.SetFormat(t.GetFormat()); for(int i = 0; i < pos.GetCount() - 1; i++) { tab.AddColumn(pos[i + 1] - pos[i]); } for(int i = 0; i < t.GetRows(); i++) { int s = srow[i]; int nx = b.rown[i]; int xn = 0; int xi = 0; for(int j = 0; j < nx; j++) { Size span = t.GetSpan(i, j); xn += span.cx; int nxi = pos.Find(xn * 10000 / s); tab.SetPick(i, xi, t.GetPick(i, j)); tab.SetFormat(i, xi, t.GetFormat(i, j)); tab.SetSpan(i, xi, max(span.cy - 1, 0), nxi - xi - 1); xi = nxi; } } table.Drop(); if(table.GetCount()) table.Top().text.CatPick(pick(tab)); else target.CatPick(pick(tab)); oldtab = false; }
Rect Ctrl::GetVirtualWorkArea() { GuiLock __; static Rect r; if(r.right == 0) { r = GetPrimaryWorkArea(); Array<Rect> rc; GetWorkArea(rc); for(int i = 0; i < rc.GetCount(); i++) r |= rc[i]; } return r; }
Rect Ctrl::GetWorkArea() const { GuiLock __; static Array<Rect> rc; if(rc.IsEmpty()) GetWorkArea(rc); Point pt = GetScreenRect().TopLeft(); for (int i = 0; i < rc.GetCount(); i++) if(rc[i].Contains(pt)) return rc[i]; return GetPrimaryWorkArea(); }
bool IdeIconDes::Load(const char *_filename) { Clear(); filename = _filename; filetime = FileGetTime(filename); Array<ImlImage> m; int f; if(!LoadIml(LoadFile(filename), m, f)) return false; format = f; for(int i = 0; i < m.GetCount(); i++) AddImage(m[i].name, m[i].image, m[i].exp); return true; }
Rect Ctrl::GetPrimaryWorkArea() { GuiLock __; static Rect r; if (r.right == 0) { Array<Rect> rc; GetWorkArea(rc); #if GTK_CHECK_VERSION(2, 20, 0) int primary = gdk_screen_get_primary_monitor(gdk_screen_get_default()); #else int primary = 0; #endif primary >= 0 && primary < rc.GetCount() ? r = rc[primary] : r = GetVirtualScreenArea(); } return r; }
void ProcessList::Fill() { Process.Reset(); Process.AddColumn("Id", 6); Process.AddColumn("Priority", 6); Process.AddColumn("Program", 12); Array<int64> pidL; pidL.Clear(); Array<String> pNames; if (!GetProcessList(pidL, pNames)) Process.Add("Error getting process info"); else { for (int i = 0; i < pidL.GetCount(); ++i) { int priority = GetProcessPriority(pidL[i]); Process.Add(Format64(pidL[i]), priority >= 0? FormatInt(priority): "Not accesible", pNames[i]); } } ButUpdate.WhenPush = THISBACK(ButUpdate_Push); }
void Keyb_SendKeys(String text, long finalDelay, long delayBetweenKeys) { Array <wchar> virt; bool inKey = false; String key = ""; WString wtext(text); for (int i = 0; i < wtext.GetCount(); ++i) { bool vk = false; Sleep(delayBetweenKeys); wchar c = wtext[i]; if (c == '{') inKey = true; else if (c == '}') { if (key == "{") c = '{'; else { c = GetKeyCode(key); vk = true; } inKey = false; key = ""; } else if (inKey == 1) key.Cat(c); else if (c == '\n') { c = GetKeyCode("RETURN"); vk = true; } if (inKey == false) { if (!vk) PressKey(c); #if defined(PLATFORM_WIN32) || defined (PLATFORM_WIN64) else { PressKeyVK(c, true); virt.Add(c); } #endif } } #if defined(PLATFORM_WIN32) || defined (PLATFORM_WIN64) for (int i = 0; i < virt.GetCount(); ++i) PressKeyVK(virt[i], false, true); #endif Sleep(finalDelay); }
bool GetBatteryInfo(bool &present/*, int &designCapacity, int &lastFullCapacity, String &vendor, String &type, String &model, String &serial*/) { Array<String> files = SearchFile("/proc/acpi/battery", "info"); if (files.GetCount() == 0) return false; StringParse info = LoadFile_Safe(files[0]); if (info == "") return false; info.GoAfter_Init("present", ":"); present = info.GetText() == "yes"; /* info.GoAfter_Init("design capacity", ":"); designCapacity = info.GetInt(); info.GoAfter_Init("last full capacity", ":");lastFullCapacity = info.GetInt(); info.GoAfter_Init("OEM info", ":"); vendor = info.GetText(); info.GoAfter_Init("battery type", ":"); type = info.GetText(); info.GoAfter_Init("model number", ":"); model = info.GetText(); info.GoAfter_Init("serial number", ":"); serial = info.GetText(); */ return true; }
void RegisterClass(MetaClass *meta, Dictionary *properties) { ClassEntry *entry = ClassEntry::Alloc()->InitWithClass(meta, properties); spinlock_lock(&_matchingLock); _registeredClasses->AddObject(entry); Array *providersCopy = Array::Alloc()->InitWithArray(_providers); spinlock_unlock(&_matchingLock); // Ping all provider to allow them to match against the newly added class for(size_t i = 0; i < providersCopy->GetCount(); i ++) { Service *provider = providersCopy->GetObjectAtIndex<Service>(i); provider->StartMatching(); } providersCopy->Release(); }
virtual Image Make() const { Vector<String> s = Split(id, ':'); if(s.GetCount() != 3) return LayImg::ImageError(); Array<ImlImage> iml; int f; LoadIml(LoadFile(SourcePath(s[0], s[1])), iml, f); bool recolor = false; if(*s[2].Last() == '*') { s[2].Trim(s[2].GetLength() - 1); recolor = true; } Image m = LayImg::ImageError(); for(int i = 0; i < iml.GetCount(); i++) if(iml[i].name == s[2]) { m = iml[i].image; break; } return recolor ? AdjustColors(m) : m; }
//установка годов в которые среди списка есть релизы void AnimeList::SetupYears() { parameters.years.Clear(); parameters.years.Add("All Years"); parameters.years.SetIndex(0); Array<int> year; int last; bool a = false; if(!mainArray.IsEmpty()) { for(int i=0;i<mainArray.GetCount();i++) { a = false; if(year.GetCount() == 0) { year.Add(mainArray[i].Release.year); last = year.GetCount() - 1; } else { for(int j=0;j<year.GetCount();j++) if(mainArray[i].Release.year == year[j]) { a = true; break; } if(!a) { year.Add(mainArray[i].Release.year); last = year.GetCount() - 1; } for(int i=0;i<year.GetCount();i++) if(year[last]<year[i]) { year.Swap(i, last); } } } for(int i=year.GetCount()-1;i>=0;i--) parameters.years.Add(year[i]); } }
void Array<T>::Insert(int i, const Array& x) { Insert(i, x, 0, x.GetCount()); }