void Directx::TRenderTarget::Bind(TContext& ContextDx) { auto& Context = ContextDx.LockGetContext(); // save rendertargets to restore mRestoreRenderTarget.Release(); mRestoreStencilTarget.Release(); Context.OMGetRenderTargets( 1, &mRestoreRenderTarget.mObject, &mRestoreStencilTarget.mObject ); // set new render target Context.OMSetRenderTargets( 1, &mRenderTargetView.mObject, nullptr ); // set viewport D3D11_VIEWPORT Viewport; ZeroMemory(&Viewport, sizeof(D3D11_VIEWPORT)); Viewport.TopLeftX = 0; Viewport.TopLeftY = 0; Viewport.Width = GetMeta().GetWidth(); Viewport.Height = GetMeta().GetHeight(); Context.RSSetViewports( 1, &Viewport ); ContextDx.Unlock(); }
bool CWizDatabase::getUserGroupInfo(CWizGroupDataArray& arrayGroup) { CString strTotal; bool bExist; if (!GetMeta(g_strGroupSection, "Count", strTotal, "", &bExist)) { return false; } if (!bExist) { return false; } int nTotal = strTotal.toInt(); for (int i = 0; i < nTotal; i++) { QString strGroupGUID = GetMetaDef(g_strGroupSection, QString::number(i)); QString strGroupName = GetMetaDef(g_strGroupSection, strGroupGUID); WIZGROUPDATA group; group.strGroupGUID = strGroupGUID; group.strGroupName = strGroupName; arrayGroup.push_back(group); } return true; }
std::wstring GetName() const { u16 meta = GetMeta(); std::wstring names[] = { L"Sand", L"Red Sand" }; return names[meta]; }
std::wstring GetName() const { u16 meta = GetMeta(); std::wstring names[] = { L"Dirt", L"Coarse Dirt", L"Podzol" }; return names[meta]; }
int Ardb::IncrbyFloat(const DBID& db, const Slice& key, double increment, double& value) { CommonMetaValue* meta = GetMeta(db, key, false); StringMetaValue* smeta = NULL; if (NULL != meta) { if (meta->header.type != STRING_META) { DELETE(meta); return ERR_INVALID_TYPE; } smeta = (StringMetaValue*) meta; smeta->value.ToNumber(); if (smeta->value.type == BYTES_VALUE) { DELETE(smeta); return ERR_INVALID_TYPE; } smeta->value.IncrbyFloat(increment); value = smeta->value.double_value; DELETE(smeta); } else { StringMetaValue nsmeta; nsmeta.value.SetDoubleValue(increment); KeyObject k(key, KEY_META, db); SetMeta(k, nsmeta); value = increment; } return 0; }
bool CWizDatabase::getBizGroupInfo(QMap<QString, QString>& bizInfo) { CString strTotal; bool bExist; if(!GetMeta(g_strBizGroupSection, "Count", strTotal, "", &bExist)) { return false; } if (!bExist) { return true; } bizInfo.clear(); int nTotal = strTotal.toInt(); for (int i = 0; i < nTotal; i++) { QString strBizGUID = GetMetaDef(g_strBizGroupSection, QString::number(i)); QString strBizName = GetMetaDef(g_strBizGroupSection, strBizGUID); bizInfo[strBizGUID] = strBizName; } return true; }
bool CWizDatabase::getUserGroupInfo(CWizGroupDataArray& arrayGroup) { CString strTotal; bool bExist; if (!GetMeta(g_strGroupSection, "Count", strTotal, "", &bExist)) { return false; } // it's ok, user has no group data if (!bExist) { return true; } int nTotal = strTotal.toInt(); for (int i = 0; i < nTotal; i++) { WIZGROUPDATA group; group.strGroupGUID = GetMetaDef(g_strGroupSection, QString::number(i)); group.strGroupName = GetMetaDef(g_strGroupSection, group.strGroupGUID); group.bizGUID = GetMetaDef(g_strBizGroupSection, group.strGroupGUID); if (!group.bizGUID.isEmpty()) group.bizName = GetMetaDef(g_strBizGroupSection, group.bizGUID); arrayGroup.push_back(group); } return true; }
std::wstring GetName() const { u16 meta = GetMeta(); std::wstring names[] = { L"Oak Wood Planks", L"Spruce Wood Planks", L"Birch Wood Planks", L"Jungle Wood Planks", L"Acacia Wood Planks", L"Dark Oak Wood Planks" }; return names[meta]; }
std::wstring GetName() const { u16 meta = GetMeta(); std::wstring names[] = { L"Stone", L"Granite", L"Polished Granite", L"Diorite", L"Polished Diorite", L"Andesite", L"Polished Andesite" }; return names[meta]; }
std::wstring GetName() const { u16 meta = GetMeta(); meta &= 7; std::wstring names[] = { L"Oak Sapling", L"Spruce Sapling", L"Birch Sapling", L"Jungle Sapling", L"Acacia Sapling", L"Dark Oak Sapling", }; return names[meta]; }
bool CWizDatabase::GetPassword(CString& strPassword) { bool bExists = false; if (!GetMeta(g_strAccountSection, "Password", strPassword, "", &bExists)) { TOLOG("Failed to get password while GetPassword"); return false; } if (strPassword.IsEmpty()) return true; strPassword = WizDecryptPassword(strPassword); return true; }
bool CFfmpegDec::SetMetaData(FILE *_in, CAudioMetaData* m, bool save_cover) { if (!meta_data_valid) { if (!Init(_in, (const CFile::FileType) m->type)) return false; mutex.lock(); int ret = avformat_find_stream_info(avc, NULL); if (ret < 0) { mutex.unlock(); DeInit(); printf("avformat_find_stream_info error %d\n", ret); return false; } mutex.unlock(); if (!is_stream) { GetMeta(avc->metadata); for(unsigned int i = 0; i < avc->nb_streams; i++) { if (avc->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) GetMeta(avc->streams[i]->metadata); } } //fseek((FILE *) in, 0, SEEK_SET); #ifdef FFDEC_DEBUG av_dump_format(avc, 0, "", 0); #endif codec = NULL; best_stream = av_find_best_stream(avc, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0); if (best_stream < 0) { DeInit(); return false; } if (!codec) codec = avcodec_find_decoder(avc->streams[best_stream]->codec->codec_id); samplerate = avc->streams[best_stream]->codec->sample_rate; mChannels = av_get_channel_layout_nb_channels(avc->streams[best_stream]->codec->channel_layout); std::stringstream ss; if (codec && codec->long_name != NULL) type_info = codec->long_name; else if(codec && codec->name != NULL) type_info = codec->name; else type_info = "unknown"; ss << " / " << mChannels << " channel" << ( mChannels > 1 ? "s" : ""); type_info += ss.str(); bitrate = 0; total_time = 0; if (avc->duration != int64_t(AV_NOPTS_VALUE)) total_time = avc->duration / int64_t(AV_TIME_BASE); printf("CFfmpegDec: format %s (%s) duration %ld\n", avc->iformat->name, type_info.c_str(), total_time); for(unsigned int i = 0; i < avc->nb_streams; i++) { if (avc->streams[i]->codec->bit_rate > 0) bitrate += avc->streams[i]->codec->bit_rate; if (save_cover && (avc->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC)) { mkdir(COVERDIR, 0755); std::string cover(COVERDIR); cover += "/" + to_string(cover_count++) + ".jpg"; FILE *f = fopen(cover.c_str(), "wb"); if (f) { AVPacket *pkt = &avc->streams[i]->attached_pic; fwrite(pkt->data, pkt->size, 1, f); fclose(f); m->cover = cover; m->cover_temporary = true; } } } if(!total_time && m->filesize && bitrate) total_time = 8 * m->filesize / bitrate; meta_data_valid = true; m->changed = true; } if (!is_stream) { m->title = title; m->artist = artist; m->date = date; m->album = album; m->genre = genre; m->total_time = total_time; } m->type_info = type_info; // make sure bitrate is set to prevent refresh metadata from gui, its a flag m->bitrate = bitrate ? bitrate : 1; m->samplerate = samplerate; return true; }
wxString MetadataCtrl::FormatLabel(const wxString & format, MyFrame * frame, bool useLua) { if (! frame || ! frame->GetPuzzle().IsOk()) return wxEmptyString; wxString result; const puz::Puzzle & puz = frame->GetPuzzle(); wxStringTokenizer tok(format, _T("%"), wxTOKEN_RET_EMPTY_ALL); bool ismeta = false; // Is the current token a metadata value? while (tok.HasMoreTokens()) { if (! ismeta) { result << tok.GetNextToken(); ismeta = true; // The next token is a metadata value } else // We're in the middle of a percent-delimited string { wxString str = tok.GetNextToken(); if (str.empty()) // This is a literal % { result << _T("%"); } else // This is a metadata value { str = GetMeta(str, frame); #if XWORD_USE_LUA if (useLua) { if (str.empty()) { result << _T("nil"); } else { str.Replace("'", "\\'"); result << _T("'") << str << _T("'"); } } else // plain text result << str; #else // ! XWORD_USE_LUA result << str; #endif // XWORD_USE_LUA } ismeta = false; // The next token is plain text } } #if XWORD_USE_LUA if (! useLua) return result; // Process this with lua wxLuaState & luastate = wxGetApp().GetwxLuaState(); lua_State * L = luastate.GetLuaState(); // Compile a lua function taking a puzzle argument if (result.Find(_T("return")) == -1) // Make sure we're returning something result = _T("return ") + result; wxLuaCharBuffer code(wxString::Format(_T("return function (puzzle) %s end"), (const wxChar *)result.c_str())); // Compile and run the code if (luaL_loadbuffer(L, code.GetData(), code.Length(), "") == 0) { if (lua_pcall(L, 0, 1, 0) == 0) { if (lua_isfunction(L, -1)) // Make sure we got a function { // Call this function luapuz_pushPuzzle(L, &frame->GetPuzzle()); if (lua_pcall(L, 1, 1, 0) == 0) { // Check the result if (luastate.lua_IsString(-1)) { result = luastate.lua_TowxString(-1); lua_pop(L, 1); return result; } // Clean up the stack lua_pop(L, 1); } } else // Clean up the stack { lua_pop(L, 1); } } } else { // Return the error result = luastate.lua_TowxString(-1); lua_pop(L, 1); return result; } return wxEmptyString; #else // ! XWORD_USE_LUA return result; #endif // XWORD_USE_LUA }