#include "stdafx.h" #include #include #include "resource.h" #include "prefs.h" #define SWAPRB(x) ( (((x)>>16)&0xff) | ((x)&0xff00) | (((x)&0xff)<<16) ) Prefs prefs; void Prefs::open(){ char *p=getenv( "blitzpath" ); if( !p ){ AfxMessageBox( "blitzpath environment variable not found!",MB_TOPMOST|MB_SETFOREGROUND|MB_ICONINFORMATION ); ExitProcess(0); } homeDir=p; AddFontResource( (homeDir+"/cfg/blitz.fon").c_str() ); setDefault(); bool prg_windowed; ifstream in( (homeDir+"/cfg/blitzide.prefs").c_str() ); if( !in.good() ) return; while( !in.eof() ){ string t;in>>t; if( !t.size() ) continue; while( in.peek()=='\t' ) in.ignore(); if( t=="prg_debug" ) in>>prg_debug; else if( t=="prg_lastbuild" ) getline( in,prg_lastbuild ); else if( t=="prg_windowed" ) in>>prg_windowed; else if( t=="win_maximized" ) in>>win_maximized; else if( t=="win_notoolbar" ) in>>win_notoolbar; else if( t=="win_rect" ){ in>>win_rect.left;in>>win_rect.top; in>>win_rect.right;in>>win_rect.bottom; }else if( t.substr( 0,5 )=="font_" ){ string s;int h;in>>s;in>>h; t=t.substr( 5 ); if( t=="editor" ){ font_editor=s;font_editor_height=h; }else if( t=="tabs" ){ font_tabs=s;font_tabs_height=h; }else if( t=="debug" ){ font_debug=s;font_debug_height=h; } }else if( t.substr( 0,4 )=="rgb_" ){ t=t.substr(4); string s;in>>s;int rgb=0; for( int k=0;k>edit_tabs; }else if( t=="edit_blkcursor" ){ in>>edit_blkcursor; }else if( t=="edit_backup" ){ in>>edit_backup; }else if( t=="img_toolbar" ){ getline( in,img_toolbar ); }else if( t=="cmd_line" ){ getline( in,cmd_line ); }else if( t=="file_recent" ){ string l;getline( in,l ); if( recentFiles.size()<10 ) recentFiles.push_back( l ); }else{ string s="Unrecognized option '"+t+"' in blitzide.prefs"; AfxMessageBox( "Error in preferences file" ); setDefault(); return; } } createFonts(); } void Prefs::close(){ ofstream out( (homeDir+"/cfg/blitzide.prefs").c_str() ); if( !out.good() ) return; out<<"prg_debug\t"<