LogDialog::LogDialog(wxWindow* parent):_LogDialog(parent) { m_canClose = false; m_text = _(" --------------- Log starts at: ") + wxNow() + " -------------------\n"; m_textCtrl11->SetValue(m_text); }
void SetIP(const wxString& buff) { wxRegEx re(m_ipRegex->GetValue(), wxRE_ADVANCED); if (!re.Matches(buff) || re.GetMatch(buff).IsEmpty()) { SetStatusText(wxT("Błąd parsowania IP")); return; } const wxString ip(re.GetMatch(buff)); m_ip->SetValue(ip); m_lastIpTime = wxDateTime::Now(); SetStatusText("IP: " + ip + " z godziny " + m_lastIpTime.Format("%H:%M (%S sek)")); const wxFileName fn(m_ipDestFile->GetPath()); wxFile ipFile; if (!ipFile.Create(fn.GetFullPath(), true)) { wxLogError(wxT("Błąd podczas tworzenia pliku")); return; } ipFile.Write(ip + "\n" + wxNow() + "\n"); }
void wxExApp::OnAssertFailure( const wxChar* file, int line, const wxChar* func, const wxChar* cond, const wxChar* msg) { std::wcout << wxNow() << ": OnAssertFailure: file: " << file << " line: " << line << " func: " << func << " cond: " << cond << " msg: " << msg << "\n"; }
/* TextureXList::writeTEXTURESData * Writes the texture list in TEXTURES format to [entry] Returns true * on success, false otherwise *******************************************************************/ bool TextureXList::writeTEXTURESData(ArchiveEntry* entry) { // Check format if (txformat != TXF_TEXTURES) return false; wxLogMessage("Writing ZDoom text format TEXTURES entry"); // Generate a big string :P string textures_data = "// Texture definitions generated by SLADE3\n// on " + wxNow() + "\n\n"; for (unsigned a = 0; a < textures.size(); a++) textures_data += textures[a]->asText(); textures_data += "// End of texture definitions\n"; wxLogMessage("%u texture%s written on %u bytes", textures.size(), textures.size()<2?"":"s", textures_data.length()); // Write it to the entry return entry->importMem(textures_data.ToAscii(), textures_data.length()); }
// ----------------------------------------------------------------------------- // Writes the texture list in TEXTURES format to [entry]. // Returns true on success, false otherwise // ----------------------------------------------------------------------------- bool TextureXList::writeTEXTURESData(ArchiveEntry* textures) { // Check format if (txformat_ != Format::Textures) return false; Log::info("Writing ZDoom text format TEXTURES entry"); // Generate a big string :P auto textures_data = "// Texture definitions generated by SLADE3\n// on " + wxNow().ToStdString() + "\n\n"; for (auto& texture : textures_) textures_data += texture->asText(); textures_data += "// End of texture definitions\n"; Log::info( "{} texture{} written on {} bytes", textures_.size(), textures_.size() < 2 ? "" : "s", textures_data.length()); // Write it to the entry return textures->importMem(textures_data.data(), textures_data.size()); }
bool wxGISServer::SetupLog(const wxString &sLogPath) { if(sLogPath.IsEmpty()) { wxLogError(_("wxGISServer: Failed to get log folder")); return false; } if(!wxDirExists(sLogPath)) wxFileName::Mkdir(sLogPath, 0777, wxPATH_MKDIR_FULL); wxDateTime dt(wxDateTime::Now()); wxString logfilename = sLogPath + wxFileName::GetPathSeparator() + wxString::Format(wxT("srvlog_%.4d%.2d%.2d.log"),dt.GetYear(), dt.GetMonth() + 1, dt.GetDay()); if(m_LogFile.IsOpened()) m_LogFile.Close(); if(!m_LogFile.Open(logfilename.GetData(), wxT("a+"))) wxLogError(_("wxGISServer: Failed to open log file %s"), logfilename.c_str()); wxLog::SetActiveTarget(new wxLogStderr(m_LogFile.fp())); #ifdef WXGISPORTABLE wxLogMessage(wxT("Portable")); #endif wxLogMessage(wxT(" ")); wxLogMessage(wxT("####################################################################")); wxLogMessage(wxT("## %s ##"),wxNow().c_str()); wxLogMessage(wxT("####################################################################")); long dFreeMem = wxMemorySize(wxGetFreeMemory() / 1048576).ToLong(); wxLogMessage(_("HOST '%s': OS desc - %s, free memory - %u Mb"), wxGetFullHostName().c_str(), wxGetOsDescription().c_str(), dFreeMem); wxLogMessage(_("wxGISServer: %s %s is initializing..."), GetAppName().c_str(), GetAppVersionString().c_str()); wxLogMessage(_("wxGISServer: Log file: %s"), logfilename.c_str()); wxString sCPLLogPath = sLogPath + wxFileName::GetPathSeparator() + wxString(wxT("gdal_log_cat.txt")); CPLString szCPLLogPath(sCPLLogPath.mb_str(wxConvUTF8)); CPLSetConfigOption("CPL_LOG", szCPLLogPath ); return true; }
bool wxGISApplication::SetupLog(const wxString &sLogPath, const wxString &sNamePrefix) { if(sLogPath.IsEmpty()) { wxLogError(_("wxGISApplication: Failed to get log folder")); return false; } if(!wxDirExists(sLogPath)) wxFileName::Mkdir(sLogPath, 0777, wxPATH_MKDIR_FULL); wxDateTime dt(wxDateTime::Now()); wxString logfilename = sLogPath + wxFileName::GetPathSeparator() + wxString::Format(wxT("%slog_%.4d%.2d%.2d.log"),sNamePrefix.c_str(), dt.GetYear(), dt.GetMonth() + 1, dt.GetDay()); if(m_LogFile.IsOpened()) m_LogFile.Close(); if(!m_LogFile.Open(logfilename.GetData(), wxT("a+"))) wxLogError(_("wxGISApplication: Failed to open log file %s"), logfilename.c_str()); wxLog::SetActiveTarget(new wxLogStderr(m_LogFile.fp())); #ifdef WXGISPORTABLE wxLogMessage(wxT("Portable")); #endif wxLogMessage(wxT(" ")); wxLogMessage(wxT("####################################################################")); wxLogMessage(wxT("## %s ##"),wxNow().c_str()); wxLogMessage(wxT("####################################################################")); wxLongLong nFreeMem = wxGetFreeMemory(); wxString sFreeMem = wxFileName::GetHumanReadableSize(wxULongLong(nFreeMem.GetHi(), nFreeMem.GetLo())); // long dFreeMem = wxMemorySize(wxGetFreeMemory() / 1048576).ToLong(); wxLogMessage(_("HOST '%s': OS desc - %s, free memory - %s"), wxGetFullHostName().c_str(), wxGetOsDescription().c_str(), sFreeMem.c_str()); wxLogMessage(_("wxGISApplication: %s %s is initializing..."), GetAppName().c_str(), GetAppVersionString().c_str()); wxLogMessage(_("wxGISApplication: Log file: %s"), logfilename.c_str()); return true; }
/* MainApp::initLogFile * Sets up the SLADE log file *******************************************************************/ void MainApp::initLogFile() { // Set wxLog target(s) wxLog::SetActiveTarget(new SLADELog()); FILE* log_file = fopen(CHR(appPath("slade3.log", DIR_DATA)), "wt"); new wxLogChain(new wxLogStderr(log_file)); // Write logfile header string year = wxNow().Right(4); wxLogMessage("SLADE - It's a Doom Editor"); wxLogMessage("Version %s", Global::version); wxLogMessage("Written by Simon Judd, 2008-%s", year); #ifdef SFML_VERSION_MAJOR wxLogMessage("Compiled with wxWidgets %i.%i.%i and SFML %i.%i", wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER, SFML_VERSION_MAJOR, SFML_VERSION_MINOR); #else wxLogMessage("Compiled with wxWidgets %i.%i.%i", wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER); #endif wxLogMessage("--------------------------------"); // Set up FreeImage to use our log: FreeImage_SetOutputMessage(FreeImageErrorHandler); }
/* MainWindow::handleAction * Handles the action [id]. Returns true if the action was handled, * false otherwise *******************************************************************/ bool MainWindow::handleAction(string id) { // We're only interested in "main_" actions if (!id.StartsWith("main_")) return false; // File->Exit if (id == "main_exit") { Close(); return true; } // Edit->Undo if (id == "main_undo") { panel_archivemanager->undo(); return true; } // Edit->Redo if (id == "main_redo") { panel_archivemanager->redo(); return true; } // Edit->Set Base Resource Archive if (id == "main_setbra") { wxDialog dialog_ebr(this, -1, "Edit Base Resource Archives", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER); BaseResourceArchivesPanel brap(&dialog_ebr); wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL); sizer->Add(&brap, 1, wxEXPAND|wxALL, 4); sizer->Add(dialog_ebr.CreateButtonSizer(wxOK|wxCANCEL), 0, wxEXPAND|wxLEFT|wxRIGHT|wxDOWN, 4); dialog_ebr.SetSizer(sizer); dialog_ebr.Layout(); dialog_ebr.SetInitialSize(wxSize(500, 300)); dialog_ebr.CenterOnParent(); if (dialog_ebr.ShowModal() == wxID_OK) theArchiveManager->openBaseResource(brap.getSelectedPath()); return true; } // Edit->Preferences if (id == "main_preferences") { PreferencesDialog::openPreferences(this); return true; } // View->Archive Manager if (id == "main_showam") { wxAuiManager *m_mgr = wxAuiManager::GetManager(panel_archivemanager); wxAuiPaneInfo& p_inf = m_mgr->GetPane("archive_manager"); p_inf.Show(!p_inf.IsShown()); m_mgr->Update(); return true; } // View->Console if (id == "main_showconsole") { wxAuiManager *m_mgr = wxAuiManager::GetManager(panel_archivemanager); wxAuiPaneInfo& p_inf = m_mgr->GetPane("console"); p_inf.Show(!p_inf.IsShown()); p_inf.MinSize(200, 128); m_mgr->Update(); return true; } // View->Undo History if (id == "main_showundohistory") { wxAuiManager *m_mgr = wxAuiManager::GetManager(panel_archivemanager); wxAuiPaneInfo& p_inf = m_mgr->GetPane("undo_history"); p_inf.Show(!p_inf.IsShown()); m_mgr->Update(); return true; } // Help->About if (id == "main_about") { wxAboutDialogInfo info; info.SetName("SLADE"); info.SetVersion("v" + Global::version); info.SetWebSite("http://slade.mancubus.net"); info.SetDescription("It's a Doom Editor"); // Set icon string icon_filename = appPath("slade.ico", DIR_TEMP); theArchiveManager->programResourceArchive()->getEntry("slade.ico")->exportFile(icon_filename); info.SetIcon(wxIcon(icon_filename, wxBITMAP_TYPE_ICO)); wxRemoveFile(icon_filename); string year = wxNow().Right(4); info.SetCopyright(S_FMT("(C) 2008-%s Simon Judd <*****@*****.**>", year.c_str())); wxAboutBox(info); return true; } // Help->Online Documentation if (id == "main_onlinedocs") { wxLaunchDefaultBrowser("http://slade-editor.wikia.com"); return true; } // Unknown action return false; }
bool wxDebugContext::PrintStatistics(bool detailed) { { const wxChar* appName = wxT("application"); wxString appNameStr; if (wxTheApp) { appNameStr = wxTheApp->GetAppName(); appName = appNameStr.c_str(); OutputDumpLine(wxT("----- Memory statistics of %s at %s -----"), appName, static_cast<const wxChar *>(wxNow().c_str())); } else { OutputDumpLine( wxT("----- Memory statistics -----") ); } } bool currentMode = GetDebugMode(); SetDebugMode(false); long noNonObjectNodes = 0; long noObjectNodes = 0; long totalSize = 0; wxDebugStatsStruct *list = NULL; wxMemStruct *from = (checkPoint ? checkPoint->m_next : NULL ); if (!from) from = wxDebugContext::GetHead (); wxMemStruct *st; for (st = from; st != 0; st = st->m_next) { void* data = st->GetActualData(); if (detailed && (data != (void*) wxLog::GetActiveTarget())) { wxChar *className = (wxChar*) wxT("nonobject"); if (st->m_isObject && st->GetActualData()) { wxObject *obj = (wxObject *)st->GetActualData(); if (obj->GetClassInfo()->GetClassName()) className = (wxChar*)obj->GetClassInfo()->GetClassName(); } wxDebugStatsStruct *stats = FindStatsStruct(list, className); if (!stats) { stats = (wxDebugStatsStruct *)malloc(sizeof(wxDebugStatsStruct)); stats->instanceClass = className; stats->instanceCount = 0; stats->totalSize = 0; list = InsertStatsStruct(list, stats); } stats->instanceCount ++; stats->totalSize += st->RequestSize(); } if (data != (void*) wxLog::GetActiveTarget()) { totalSize += st->RequestSize(); if (st->m_isObject) noObjectNodes ++; else noNonObjectNodes ++; } } if (detailed) { while (list) { OutputDumpLine(wxT("%ld objects of class %s, total size %ld"), list->instanceCount, list->instanceClass, list->totalSize); wxDebugStatsStruct *old = list; list = old->next; free((char *)old); } OutputDumpLine(wxEmptyString); } SetDebugMode(currentMode); OutputDumpLine(wxT("Number of object items: %ld"), noObjectNodes); OutputDumpLine(wxT("Number of non-object items: %ld"), noNonObjectNodes); OutputDumpLine(wxT("Total allocated size: %ld"), totalSize); OutputDumpLine(wxEmptyString); OutputDumpLine(wxEmptyString); return true; }
bool wxDebugContext::Dump(void) { { const wxChar* appName = wxT("application"); wxString appNameStr; if (wxTheApp) { appNameStr = wxTheApp->GetAppName(); appName = appNameStr.c_str(); OutputDumpLine(wxT("----- Memory dump of %s at %s -----"), appName, static_cast<const wxChar *>(wxNow().c_str())); } else { OutputDumpLine( wxT("----- Memory dump -----") ); } } TraverseList ((PmSFV)&wxMemStruct::Dump, (checkPoint ? checkPoint->m_next : NULL)); OutputDumpLine(wxEmptyString); OutputDumpLine(wxEmptyString); return true; }
void RgbEffects::RenderRipple(int Object_To_Draw, int Movement) { int x,y,i,i7,ColorIdx; int xc,yc; #if 0 if(step<1) step=1; if(Use_All_Colors) srand (time(NULL)); // for Use_All_Colors effect, make lights be random else srand(1); // else always have the same random numbers for each frame (state) #endif wxImage::HSVValue hsv; // we will define an hsv color model. The RGB colot model would have been "wxColour color;" srand (time(NULL)); size_t colorcnt=GetColorCount(); i=0; double position = GetEffectTimeIntervalPosition(); // how far are we into the row> value is 0.0 to 1.0 float rx; xc = BufferWi/2; yc=BufferHt/2; int on_off=0; int slices=200; int istate=state/slices; // istate will be a counter every slices units of state. each istate is a square wave int imod=(state/(slices/10))%10; // divide this square int icolor=istate%colorcnt; wxString TimeNow =wxNow(); rx=(state%slices)/(slices*1.0); int x1 = xc - (xc*rx); int x2 = xc + (xc*rx); int y1 = yc - (yc*rx); int y2 = yc + (yc*rx); enum {Square, Circle, Triangle} shape = Circle; double radius; // debug(10, "%s:%6d istate=%4d imod=%4d icolor=%1d", (const char*)TimeNow,state,istate,imod,icolor); ColorIdx=rand()% colorcnt; // Select random numbers from 0 up to number of colors the user has checked. 0-5 if 6 boxes checked palette.GetHSV(ColorIdx, hsv); // Now go and get the hsv value for this ColorIdx int explode; switch (Object_To_Draw) { case RENDER_RIPPLE_SQUARE: explode=1; if(Movement==MOVEMENT_EXPLODE) { // This is the object expanding out, or explode looikng int x1 = xc - (xc*rx); int x2 = xc + (xc*rx); int y1 = yc - (yc*rx); int y2 = yc + (yc*rx); for(y=y1; y<=y2; y++) { SetP(x1,y,hsv); // Turn pixel SetP(x2,y,hsv); // Turn pixel } for(x=x1; x<=x2; x++) { SetP(x,y1,hsv); // Turn pixel SetP(x,y2,hsv); // Turn pixel } hsv.value = (hsv.value /3)*2; for(y=y1; y<=y2; y++) { SetP(x1+1,y,hsv); // Turn pixel SetP(x2-1,y,hsv); // Turn pixel } for(x=x1; x<=x2; x++) { SetP(x,y1+1,hsv); // Turn pixel SetP(x,y2-1,hsv); // Turn pixel } hsv.value = hsv.value /3; for(y=y1; y<=y2; y++) { SetP(x1+2,y,hsv); // Turn pixel SetP(x2-2,y,hsv); // Turn pixel } for(x=x1; x<=x2; x++) { SetP(x,y1+2,hsv); // Turn pixel SetP(x,y2-2,hsv); // Turn pixel } } else if(Movement==MOVEMENT_IMPLODE) { int x1 = (xc*rx); int x2 = BufferWi - (xc*rx); int y1 = (yc*rx); int y2 = BufferHt - (yc*rx); for(y=y2; y>=y1; y--) { SetP(x1,y,hsv); // Turn pixel SetP(x2,y,hsv); // Turn pixel } for(x=x2; x>=x1; x--) { SetP(x,y1,hsv); // Turn pixel SetP(x,y2,hsv); // Turn pixel } } break; case RENDER_RIPPLE_CIRCLE: if(Movement==MOVEMENT_IMPLODE) radius = xc-(xc*rx); else radius = (xc*rx); Drawcircle( xc, yc, radius, hsv); radius=radius/2; Drawcircle( xc, yc, radius, hsv); radius=radius/2; Drawcircle( xc, yc, radius, hsv); radius=radius/2; Drawcircle( xc, yc, radius, hsv); break; case RENDER_RIPPLE_TRIANGLE: break; } }
// ----------------------------------------------------------------------------- // Handles the action [id]. // Returns true if the action was handled, false otherwise // ----------------------------------------------------------------------------- bool MainWindow::handleAction(string_view id) { // We're only interested in "main_" actions if (!StrUtil::startsWith(id, "main_")) return false; // File->Exit if (id == "main_exit") { Close(); return true; } // Edit->Undo if (id == "main_undo") { panel_archivemanager_->undo(); return true; } // Edit->Redo if (id == "main_redo") { panel_archivemanager_->redo(); return true; } // Edit->Set Base Resource Archive if (id == "main_setbra") { PreferencesDialog::openPreferences(this, "Base Resource Archive"); return true; } // Edit->Preferences if (id == "main_preferences") { PreferencesDialog::openPreferences(this); return true; } // View->Archive Manager if (id == "main_showam") { auto m_mgr = wxAuiManager::GetManager(panel_archivemanager_); auto& p_inf = m_mgr->GetPane("archive_manager"); p_inf.Show(!p_inf.IsShown()); m_mgr->Update(); return true; } // View->Console if (id == "main_showconsole") { auto m_mgr = wxAuiManager::GetManager(panel_archivemanager_); auto& p_inf = m_mgr->GetPane("console"); p_inf.Show(!p_inf.IsShown()); p_inf.MinSize(WxUtils::scaledSize(200, 128)); m_mgr->Update(); return true; } // View->Undo History if (id == "main_showundohistory") { auto m_mgr = wxAuiManager::GetManager(panel_archivemanager_); auto& p_inf = m_mgr->GetPane("undo_history"); p_inf.Show(!p_inf.IsShown()); m_mgr->Update(); return true; } // View->Show Start Page if (id == "main_showstartpage") openStartPageTab(); // Tools->Run Script if (id == "main_runscript") { ScriptManager::open(); return true; } // Help->About if (id == "main_about") { wxAboutDialogInfo info; info.SetName("SLADE"); wxString version = "v" + App::version().toString(); if (!Global::sc_rev.empty()) version = version + " (Git Rev " + Global::sc_rev + ")"; info.SetVersion(version); info.SetWebSite("http://slade.mancubus.net"); info.SetDescription("It's a Doom Editor"); // Set icon auto icon_filename = App::path(App::iconFile(), App::Dir::Temp); App::archiveManager().programResourceArchive()->entry(App::iconFile())->exportFile(icon_filename); info.SetIcon(wxIcon(icon_filename, wxBITMAP_TYPE_ICO)); wxRemoveFile(icon_filename); wxString year = wxNow().Right(4); info.SetCopyright(wxString::Format("(C) 2008-%s Simon Judd <*****@*****.**>", year)); wxAboutBox(info); return true; } // Help->Online Documentation if (id == "main_onlinedocs") { #ifdef USE_WEBVIEW_STARTPAGE openDocs(); #else wxLaunchDefaultBrowser("http://slade.mancubus.net/wiki"); #endif return true; } // Help->Check For Updates if (id == "main_updatecheck") { wxGetApp().checkForUpdates(true); return true; } // Unknown action return false; }
void LogDialog::AppendComment(const wxString& txt) { m_text.Append(wxNow() + txt + wxT("\n")); m_textCtrl11->SetValue(m_text); }
bool wxDebugContext::Dump(void) { #ifdef __WXDEBUG__ { wxChar* appName = (wxChar*) wxT("application"); wxString appNameStr; if (wxTheApp) { appNameStr = wxTheApp->GetAppName(); appName = WXSTRINGCAST appNameStr; OutputDumpLine(wxT("----- Memory dump of %s at %s -----"), appName, WXSTRINGCAST wxNow() ); } else { OutputDumpLine( wxT("----- Memory dump -----") ); } } TraverseList ((PmSFV)&wxMemStruct::Dump, (checkPoint ? checkPoint->m_next : (wxMemStruct*)NULL)); OutputDumpLine(wxEmptyString); OutputDumpLine(wxEmptyString); return true; #else return false; #endif }