Files
Dreierpack-Manager/src/obdeddi/main_win32.cpp
T

98 lines
20 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// SPDX-License-Identifier: GPL-3.0-only
#define UNICODE
#define _UNICODE
#define NOMINMAX
#include <windows.h>
#include <commctrl.h>
#include <commdlg.h>
#include <shellapi.h>
#include "obdeddi/document.hpp"
#include "obdeddi/logo_win32.hpp"
#include <algorithm>
#include <cwctype>
#include <memory>
#include <numeric>
#include <string>
#include <vector>
#ifdef _MSC_VER
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
using bmh::obdeddi::Document;
namespace {
HWND window,list,tab,search,filter,panel,status,saveButton,target,swapBox;
HFONT font;int dpi=96,mode=0,selected=-1,sortColumn=0,scrollPos=0;
bool ascending=true,updating=false,formDirty=false;
std::unique_ptr<Document> document;
std::vector<int> visible;std::vector<HWND> fields;std::wstring displayText;
constexpr int Open=100,Save=101,Search=102,Filter=103,Apply=104,Target=105,Swap=106,Move=107,Tabs=108,Logo=109;
int px(int n){return MulDiv(n,dpi,96);}
std::wstring wide(const std::string& text){int n=MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,text.data(),int(text.size()),nullptr,0);std::wstring out(size_t(n),L' ');if(n)MultiByteToWideChar(CP_UTF8,0,text.data(),int(text.size()),out.data(),n);return out;}
std::wstring original(const std::string& text){return wide(bmh::iso646de_to_utf8(text.c_str()));}
std::wstring text(HWND h){int n=GetWindowTextLengthW(h);std::wstring out(size_t(n)+1,L'\0');GetWindowTextW(h,out.data(),n+1);out.resize(size_t(n));return out;}
std::string encode(std::wstring value){std::string out;for(auto c:value){switch(c){case L'Ä':out+='[';break;case L'Ö':out+='\\';break;case L'Ü':out+=']';break;case L'ä':out+='{';break;case L'ö':out+='|';break;case L'ü':out+='}';break;case L'ß':out+='~';break;default:if(c<32||c>=127)throw std::runtime_error("Name enthaelt nicht darstellbare Original-Zeichen.");out+=char(c);}}return out;}
void error(const std::exception& e){MessageBoxW(window,wide(e.what()).c_str(),L"obdeddi",MB_OK|MB_ICONERROR);}
HWND control(const wchar_t* cls,const wchar_t* caption,DWORD style,int id,int x,int y,int w,int h,HWND parent){HWND c=CreateWindowExW(cls==std::wstring(L"EDIT")?WS_EX_CLIENTEDGE:0,cls,caption,WS_CHILD|WS_VISIBLE|style,px(x),px(y),px(w),px(h),parent,reinterpret_cast<HMENU>(INT_PTR(id)),GetModuleHandleW(nullptr),nullptr);SendMessageW(c,WM_SETFONT,reinterpret_cast<WPARAM>(font),TRUE);return c;}
int combo(HWND h){return int(SendMessageW(h,CB_GETCURSEL,0,0));}
void add(HWND h,const std::wstring& s){SendMessageW(h,CB_ADDSTRING,0,reinterpret_cast<LPARAM>(s.c_str()));}
int number(HWND h){try{auto value=text(h);size_t used=0;int n=std::stoi(value,&used);if(used!=value.size())throw std::invalid_argument("number");return n;}catch(...){throw std::runtime_error("Bitte eine ganze Zahl im angegebenen Bereich eingeben.");}}
void caption(){SetWindowTextW(window,document&&document->dirty()?L"obdeddi *":L"obdeddi");EnableWindow(saveButton,document!=nullptr);}
void setStatus(const std::wstring& value){SetWindowTextW(status,value.c_str());}
std::wstring clubName(int id){return id<0?L"Pool / Reserve":original(document->database().club_names.at(size_t(id)));}
int league(int team){int first=0;for(int l=0;l<9;++l){first+=document->profile().leagues[size_t(l)];if(team<first)return l;}return 9;}
const wchar_t* leagueName(int id){static const wchar_t* names[]={L"Bundesliga",L"2. Bundesliga",L"Regionalliga A",L"Regionalliga B",L"Oberliga",L"Spanien",L"England",L"Frankreich",L"Italien",L"Pokal / International"};return names[id];}
std::wstring cell(int id,int column){const auto& db=document->database();if(mode==0){const auto&p=db.players.at(size_t(id));switch(column){case 0:return original(p.name);case 1:return clubName(document->club_of(size_t(id)));case 2:{static const wchar_t* positions[]={L"Tor",L"Abwehr",L"Mittelfeld",L"Sturm"};return positions[p.position()];}case 3:return std::to_wstring(p.age());default:return std::to_wstring(p.strength());}}switch(column){case 0:return original(db.club_names.at(size_t(id)));case 1:return leagueName(league(id));case 2:{int count=0;for(size_t p=0;p<db.players.size();++p)count+=document->club_of(p)==id;return std::to_wstring(count);}default:return std::to_wstring(id);}}
void buildForm();void rebuild();bool apply();
void setSwapOptions(){if(!document||!target||!swapBox)return;SendMessageW(swapBox,CB_RESETCONTENT,0,0);add(swapBox,L"Nur verschieben");SendMessageW(swapBox,CB_SETITEMDATA,0,-1);int dest=combo(target);for(size_t i=0;i<document->database().players.size();++i)if(document->club_of(i)==dest){int row=int(SendMessageW(swapBox,CB_ADDSTRING,0,reinterpret_cast<LPARAM>(original(document->database().players[i].name).c_str())));SendMessageW(swapBox,CB_SETITEMDATA,WPARAM(row),LPARAM(i));}SendMessageW(swapBox,CB_SETCURSEL,0,0);}
void formField(const wchar_t* label,int row,const std::wstring& value,bool dropdown=false){control(L"STATIC",label,0,0,8,12+row*27,125,23,panel);HWND h=control(dropdown?L"COMBOBOX":L"EDIT",dropdown?L"":value.c_str(),dropdown?(CBS_DROPDOWNLIST|WS_VSCROLL|WS_TABSTOP):(ES_AUTOHSCROLL|WS_TABSTOP),200+row,138,8+row*27,228,dropdown?240:24,panel);fields.push_back(h);}
void buildForm(){updating=true;formDirty=false;selected=selected<0?-1:selected;fields.clear();target=swapBox=nullptr;HWND child=GetWindow(panel,GW_CHILD);while(child){HWND next=GetWindow(child,GW_HWNDNEXT);DestroyWindow(child);child=next;}scrollPos=0;SetScrollPos(panel,SB_VERT,0,TRUE);
if(!document||selected<0){updating=false;return;}
const auto& db=document->database();
if(mode==0){auto p=document->player(size_t(selected));formField(L"Name",0,original(p.name));formField(L"Position",1,L"",true);for(auto s:{L"Tor",L"Abwehr",L"Mittelfeld",L"Sturm"})add(fields[1],s);SendMessageW(fields[1],CB_SETCURSEL,p.position,0);
formField(L"Nationalität",2,L"",true);for(int n=0;n<62;++n)add(fields[2],original(db.club_names.at(document->profile().national_first+uint32_t(n))));SendMessageW(fields[2],CB_SETCURSEL,p.nation,0);
const wchar_t* labels[]={L"Alter (16–47)",L"Form (0–99)",L"Technik (0–99)",L"Kondition (0–99)",L"Bonus (0–127)",L"Teamplay (0–3)",L"Tempo (0–3)",L"Schuss (0–3)",L"Passspiel (0–3)",L"Zweikampf (0–3)",L"Freistoß (0–3)",L"Ecke (0–3)"};int values[]={p.age,p.form,p.technique,p.condition,p.bonus,p.skills[0],p.skills[1],p.skills[2],p.skills[3],p.skills[4],p.skills[5],p.skills[6]};for(int n=0;n<12;++n)formField(labels[n],n+3,std::to_wstring(values[n]));
control(L"STATIC",(L"Berechnete Stärke: "+std::to_wstring(db.players[size_t(selected)].strength())).c_str(),0,0,8,420,350,24,panel);
control(L"BUTTON",L"Werte übernehmen",WS_TABSTOP,Apply,8,451,358,28,panel);
control(L"STATIC",L"Classic-Eigenheit: Beim Karrierestart werden viele Spielerwerte neu erzeugt. Keine Änderung bestehender Spielstände.",0,0,8,490,358,55,panel);
control(L"STATIC",L"Zielverein",0,0,8,555,115,24,panel);target=control(L"COMBOBOX",L"",CBS_DROPDOWNLIST|WS_VSCROLL|WS_TABSTOP,Target,138,550,228,240,panel);for(int t=0;t<int(document->profile().counts.league_teams);++t)add(target,clubName(t));SendMessageW(target,CB_SETCURSEL,0,0);
control(L"STATIC",L"Tauschpartner",0,0,8,588,125,24,panel);swapBox=control(L"COMBOBOX",L"",CBS_DROPDOWNLIST|WS_VSCROLL|WS_TABSTOP,Swap,138,584,228,240,panel);setSwapOptions();control(L"BUTTON",L"Kaderwechsel",WS_TABSTOP,Move,8,621,358,28,panel);bool assigned=document->club_of(size_t(selected))>=0;EnableWindow(target,assigned);EnableWindow(swapBox,assigned);EnableWindow(GetDlgItem(panel,Move),assigned);
}else{auto id=size_t(selected);formField(L"Vereinsname",0,original(db.club_names[id]));formField(L"Trikot-Farbset",1,L"",true);for(int i=0;i<256;++i){if(std::find(db.raw_club_kit_selectors.begin(),db.raw_club_kit_selectors.end(),uint8_t(i))==db.raw_club_kit_selectors.end())continue;int row=int(SendMessageW(fields[1],CB_ADDSTRING,0,reinterpret_cast<LPARAM>((L"Farbset "+std::to_wstring(i)).c_str())));SendMessageW(fields[1],CB_SETITEMDATA,WPARAM(row),i);if(db.raw_club_kit_selectors[id]==i)SendMessageW(fields[1],CB_SETCURSEL,WPARAM(row),0);}
auto span=id<db.raw_club_short_name_offsets.size()?db.raw_club_short_name_offsets[id]:uint8_t(0);formField(L"Beginn (0–15)",2,std::to_wstring(span>>4));formField(L"Länge (1–16)",3,std::to_wstring((span&15)+1));if(id>=db.raw_club_short_name_offsets.size()){EnableWindow(fields[2],FALSE);EnableWindow(fields[3],FALSE);}
control(L"STATIC",L"Liga und Datensatzanzahlen bleiben fest. Wappen und andere Weitere Assets bleiben unverändert.",0,0,8,130,358,60,panel);control(L"BUTTON",L"Werte übernehmen",WS_TABSTOP,Apply,8,205,358,28,panel);control(L"BUTTON",L"Vereinslogo bearbeiten…",WS_TABSTOP,Logo,8,250,358,28,panel);
}
RECT r;GetClientRect(panel,&r);SCROLLINFO si{sizeof(si),SIF_RANGE|SIF_PAGE|SIF_POS,0,px(mode==0?670:250),UINT(r.bottom),0,0};SetScrollInfo(panel,SB_VERT,&si,TRUE);updating=false;
}
bool apply(){if(updating||!formDirty||!document||selected<0)return true;try{if(mode==0){auto p=document->player(size_t(selected));p.name=encode(text(fields[0]));p.position=combo(fields[1]);p.nation=combo(fields[2]);p.age=number(fields[3]);p.form=number(fields[4]);p.technique=number(fields[5]);p.condition=number(fields[6]);p.bonus=number(fields[7]);for(int i=0;i<7;++i)p.skills[i]=number(fields[size_t(i+8)]);document->set_player(size_t(selected),p);}else{int kit=int(SendMessageW(fields[1],CB_GETITEMDATA,WPARAM(combo(fields[1])),0));document->set_club(size_t(selected),encode(text(fields[0])),kit,number(fields[2]),number(fields[3]));}formDirty=false;caption();InvalidateRect(list,nullptr,FALSE);return true;}catch(const std::exception&e){error(e);return false;}}
void rebuild(){if(!document)return;updating=true;visible.clear();auto query=text(search);std::transform(query.begin(),query.end(),query.begin(),[](wchar_t c){return wchar_t(std::towlower(c));});int chosen=combo(filter);
const int total=mode==0?int(document->database().players.size()):int(document->profile().national_first);
for(int id=0;id<total;++id){if(mode==0&&chosen>0){int owner=document->club_of(size_t(id));if(chosen==1?owner!=-1:owner!=chosen-2)continue;}auto name=cell(id,0);std::transform(name.begin(),name.end(),name.begin(),[](wchar_t c){return wchar_t(std::towlower(c));});if(name.find(query)!=std::wstring::npos)visible.push_back(id);}
std::stable_sort(visible.begin(),visible.end(),[](int a,int b){int compare=0;if(mode==0&&sortColumn>=3){int x=sortColumn==3?document->database().players[size_t(a)].age():document->database().players[size_t(a)].strength(),y=sortColumn==3?document->database().players[size_t(b)].age():document->database().players[size_t(b)].strength();compare=(x>y)-(x<y);}else if(mode==1&&sortColumn>=2){int x=std::stoi(cell(a,sortColumn)),y=std::stoi(cell(b,sortColumn));compare=(x>y)-(x<y);}else compare=CompareStringOrdinal(cell(a,sortColumn).c_str(),-1,cell(b,sortColumn).c_str(),-1,TRUE)-CSTR_EQUAL;return ascending?compare<0:compare>0;});
ListView_SetItemCountEx(list,int(visible.size()),LVSICF_NOSCROLL);ListView_SetItemState(list,-1,0,LVIS_SELECTED|LVIS_FOCUSED);auto found=std::find(visible.begin(),visible.end(),selected);if(found==visible.end())selected=visible.empty()?-1:visible.front();int row=selected<0?-1:int(std::find(visible.begin(),visible.end(),selected)-visible.begin());if(row>=0)ListView_SetItemState(list,row,LVIS_SELECTED|LVIS_FOCUSED,LVIS_SELECTED|LVIS_FOCUSED);updating=false;buildForm();setStatus(std::to_wstring(visible.size())+L" Einträge · "+document->path().wstring());
}
void columns(){while(ListView_DeleteColumn(list,0)){};const wchar_t* player[]={L"Spieler",L"Verein",L"Position",L"Alter",L"Stärke"};const wchar_t* clubs[]={L"Verein",L"Liga",L"Kader",L"ID"};for(int i=0;i<(mode==0?5:4);++i){LVCOLUMNW c{};c.mask=LVCF_TEXT|LVCF_WIDTH|LVCF_FMT;c.pszText=const_cast<wchar_t*>(mode==0?player[i]:clubs[i]);c.cx=px(i==0?210:i==1?180:70);c.fmt=i>=3?LVCFMT_RIGHT:LVCFMT_LEFT;ListView_InsertColumn(list,i,&c);}}
bool save(){if(!apply())return false;if(!document)return true;try{SetCursor(LoadCursor(nullptr,IDC_WAIT));auto backup=document->save();setStatus(backup.empty()?L"Keine Änderungen.":L"Gespeichert. Backup: "+backup.wstring());caption();SetCursor(LoadCursor(nullptr,IDC_ARROW));return true;}catch(const std::exception&e){SetCursor(LoadCursor(nullptr,IDC_ARROW));error(e);return false;}}
bool mayClose(){if(!apply())return false;if(!document||!document->dirty())return true;int choice=MessageBoxW(window,L"Änderungen an der OBD speichern?",L"obdeddi",MB_YESNOCANCEL|MB_ICONQUESTION);return choice==IDNO||(choice==IDYES&&save());}
void load(const std::filesystem::path& path){try{auto next=std::make_unique<Document>(path);document=std::move(next);selected=-1;updating=true;SendMessageW(filter,CB_RESETCONTENT,0,0);add(filter,L"Alle Vereine");add(filter,L"Pool / Reserve");for(int t=0;t<int(document->profile().counts.league_teams);++t)add(filter,clubName(t));SendMessageW(filter,CB_SETCURSEL,0,0);updating=false;rebuild();caption();}catch(const std::exception&e){error(e);}}
void open(){if(!mayClose())return;wchar_t path[32768]{};OPENFILENAMEW ofn{sizeof(ofn)};ofn.hwndOwner=window;ofn.lpstrFilter=L"OpenBMH-Daten (*.obd)\0*.obd\0Alle Dateien\0*.*\0";ofn.lpstrFile=path;ofn.nMaxFile=32768;ofn.Flags=OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST|OFN_NOCHANGEDIR;if(GetOpenFileNameW(&ofn))load(path);}
LRESULT CALLBACK formProc(HWND h,UINT m,WPARAM w,LPARAM l){if(m==WM_SIZE){SCROLLINFO si{sizeof(si),SIF_PAGE};si.nPage=UINT(HIWORD(l));SetScrollInfo(h,SB_VERT,&si,TRUE);int next=GetScrollPos(h,SB_VERT);ScrollWindowEx(h,0,scrollPos-next,nullptr,nullptr,nullptr,nullptr,SW_SCROLLCHILDREN|SW_INVALIDATE|SW_ERASE);scrollPos=next;return 0;}if(m==WM_COMMAND)return SendMessageW(window,m,w,l);if(m==WM_VSCROLL||m==WM_MOUSEWHEEL){SCROLLINFO si{sizeof(si),SIF_ALL};GetScrollInfo(h,SB_VERT,&si);int next=scrollPos;if(m==WM_MOUSEWHEEL)next-=GET_WHEEL_DELTA_WPARAM(w)/WHEEL_DELTA*px(60);else switch(LOWORD(w)){case SB_LINEUP:next-=px(27);break;case SB_LINEDOWN:next+=px(27);break;case SB_PAGEUP:next-=int(si.nPage);break;case SB_PAGEDOWN:next+=int(si.nPage);break;case SB_THUMBTRACK:next=si.nTrackPos;break;};next=std::clamp(next,0,std::max(0,si.nMax-int(si.nPage)+1));ScrollWindowEx(h,0,scrollPos-next,nullptr,nullptr,nullptr,nullptr,SW_SCROLLCHILDREN|SW_INVALIDATE|SW_ERASE);scrollPos=next;SetScrollPos(h,SB_VERT,next,TRUE);return 0;}return DefWindowProcW(h,m,w,l);}
LRESULT CALLBACK proc(HWND h,UINT m,WPARAM w,LPARAM l){switch(m){case WM_SIZE:{RECT r;GetClientRect(h,&r);int right=std::max(px(420),int(r.right)-px(400));MoveWindow(list,px(12),px(92),right-px(24),r.bottom-px(132),TRUE);MoveWindow(panel,right,px(92),r.right-right-px(12),r.bottom-px(132),TRUE);MoveWindow(status,px(12),r.bottom-px(30),r.right-px(24),px(24),TRUE);return 0;}
case WM_GETMINMAXINFO:{auto p=reinterpret_cast<MINMAXINFO*>(l);p->ptMinTrackSize={px(940),px(630)};return 0;}
case WM_COMMAND:{int id=LOWORD(w),code=HIWORD(w);if(updating)return 0;if(id==Open){open();return 0;}if(id==Save){save();return 0;}if(id==Apply){if(apply())buildForm();return 0;}if(id==Search&&code==EN_CHANGE){SetTimer(h,1,180,nullptr);return 0;}if(id==Filter&&code==CBN_SELCHANGE){if(apply())rebuild();return 0;}if(id==Target&&code==CBN_SELCHANGE){setSwapOptions();return 0;}if(id==Logo){if(!apply())return 0;try{if(document&&selected>=0&&bmh::obdeddi::edit_logo(window,*document,size_t(selected)))caption();}catch(const std::exception&e){error(e);}return 0;}if(id==Move){if(!apply())return 0;try{int partner=int(SendMessageW(swapBox,CB_GETITEMDATA,WPARAM(combo(swapBox)),0));document->move_player(size_t(selected),combo(target),partner);caption();rebuild();}catch(const std::exception&e){error(e);}return 0;}if(id>=200&&id<220&&(code==EN_CHANGE||code==CBN_SELCHANGE))formDirty=true;return 0;}
case WM_TIMER:KillTimer(h,1);if(apply())rebuild();return 0;
case WM_NOTIFY:{auto hdr=reinterpret_cast<NMHDR*>(l);if(hdr->hwndFrom==tab&&hdr->code==TCN_SELCHANGING)return apply()?FALSE:TRUE;if(hdr->hwndFrom==tab&&hdr->code==TCN_SELCHANGE){mode=TabCtrl_GetCurSel(tab);selected=-1;sortColumn=0;ascending=true;EnableWindow(filter,mode==0);columns();rebuild();return 0;}if(hdr->hwndFrom!=list)return 0;
if(hdr->code==LVN_GETDISPINFOW){auto info=reinterpret_cast<NMLVDISPINFOW*>(l);if(info->item.iItem>=0&&size_t(info->item.iItem)<visible.size()){displayText=cell(visible[size_t(info->item.iItem)],info->item.iSubItem);info->item.pszText=displayText.data();}return 0;}
if(hdr->code==LVN_ITEMCHANGING&&!updating){auto n=reinterpret_cast<NMLISTVIEW*>(l);if((n->uOldState&LVIS_SELECTED)&&!(n->uNewState&LVIS_SELECTED)&&!apply())return TRUE;}
if(hdr->code==LVN_ITEMCHANGED&&!updating){auto n=reinterpret_cast<NMLISTVIEW*>(l);if((n->uNewState&LVIS_SELECTED)&&n->iItem>=0&&size_t(n->iItem)<visible.size()){selected=visible[size_t(n->iItem)];buildForm();}return 0;}
if(hdr->code==LVN_COLUMNCLICK){if(!apply())return 0;auto n=reinterpret_cast<NMLISTVIEW*>(l);ascending=sortColumn==n->iSubItem?!ascending:true;sortColumn=n->iSubItem;rebuild();return 0;}return 0;}
case WM_CLOSE:if(mayClose())DestroyWindow(h);return 0;case WM_DESTROY:PostQuitMessage(0);return 0;}
return DefWindowProcW(h,m,w,l);}
}
int WINAPI wWinMain(HINSTANCE instance,HINSTANCE,PWSTR,int show){SetProcessDPIAware();HDC dc=GetDC(nullptr);dpi=GetDeviceCaps(dc,LOGPIXELSX);ReleaseDC(nullptr,dc);font=CreateFontW(-px(14),0,0,0,FW_NORMAL,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,CLEARTYPE_QUALITY,DEFAULT_PITCH,L"Segoe UI");INITCOMMONCONTROLSEX init{sizeof(init),ICC_LISTVIEW_CLASSES|ICC_TAB_CLASSES};InitCommonControlsEx(&init);
WNDCLASSW wc{};wc.lpfnWndProc=proc;wc.hInstance=instance;wc.hCursor=LoadCursor(nullptr,IDC_ARROW);wc.hbrBackground=reinterpret_cast<HBRUSH>(COLOR_BTNFACE+1);wc.lpszClassName=L"obdeddi.window";RegisterClassW(&wc);wc.lpfnWndProc=formProc;wc.lpszClassName=L"obdeddi.form";wc.hbrBackground=reinterpret_cast<HBRUSH>(COLOR_WINDOW+1);RegisterClassW(&wc);
window=CreateWindowExW(0,L"obdeddi.window",L"obdeddi",WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN,CW_USEDEFAULT,CW_USEDEFAULT,px(1180),px(800),nullptr,nullptr,instance,nullptr);
control(L"BUTTON",L"Öffnen…",WS_TABSTOP,Open,12,12,94,28,window);saveButton=control(L"BUTTON",L"Speichern",WS_TABSTOP,Save,114,12,94,28,window);search=control(L"EDIT",L"",ES_AUTOHSCROLL|WS_TABSTOP,Search,228,14,265,25,window);SendMessageW(search,EM_SETCUEBANNER,TRUE,reinterpret_cast<LPARAM>(L"Suchen …"));filter=control(L"COMBOBOX",L"",CBS_DROPDOWNLIST|WS_VSCROLL|WS_TABSTOP,Filter,510,12,350,300,window);
tab=control(WC_TABCONTROLW,L"",WS_TABSTOP,Tabs,12,54,300,30,window);for(int i=0;i<2;++i){TCITEMW item{};item.mask=TCIF_TEXT;item.pszText=const_cast<wchar_t*>(i==0?L"Spieler":L"Vereine");TabCtrl_InsertItem(tab,i,&item);}
list=control(WC_LISTVIEWW,L"",LVS_REPORT|LVS_OWNERDATA|LVS_SINGLESEL|LVS_SHOWSELALWAYS|WS_TABSTOP,120,12,92,650,600,window);ListView_SetExtendedListViewStyle(list,LVS_EX_FULLROWSELECT|LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP);
panel=control(L"obdeddi.form",L"",WS_VSCROLL|WS_CLIPCHILDREN,0,780,92,380,600,window);SetWindowLongPtrW(panel,GWL_EXSTYLE,GetWindowLongPtrW(panel,GWL_EXSTYLE)|WS_EX_CONTROLPARENT);status=control(L"STATIC",L"Eine COMMUNITY.OBD öffnen. Weitere Assets bleiben unverändert.",SS_LEFT,0,12,720,1100,24,window);columns();caption();ShowWindow(window,show);SendMessageW(window,WM_SIZE,0,0);UpdateWindow(window);
int argumentCount=0;auto arguments=CommandLineToArgvW(GetCommandLineW(),&argumentCount);if(arguments&&argumentCount>1)load(arguments[1]);if(arguments)LocalFree(arguments);
ACCEL keys[]={{FVIRTKEY|FCONTROL,'O',Open},{FVIRTKEY|FCONTROL,'S',Save}};HACCEL accel=CreateAcceleratorTableW(keys,2);MSG message{};while(GetMessageW(&message,nullptr,0,0)>0){if(!TranslateAcceleratorW(window,accel,&message)&&!IsDialogMessageW(window,&message)){TranslateMessage(&message);DispatchMessageW(&message);}}DestroyAcceleratorTable(accel);DeleteObject(font);return int(message.wParam);}