Skip to content

Commit

Permalink
fix the problem not working Add,Delete,Return to Default Buttons in G…
Browse files Browse the repository at this point in the history
…UI. (fix #13)
  • Loading branch information
pit-ray committed Apr 2, 2021
1 parent d34eab1 commit ec84fa1
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.0.0)
project(win-vind VERSION 3.2.2)
project(win-vind VERSION 3.2.3)

if(NOT BIT_TYPE)
set(BIT_TYPE 64)
Expand Down
10 changes: 5 additions & 5 deletions build_resources/resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
IDI_ICON1 ICON DISCARDABLE "icon512.ico"

VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,2,2
FILEVERSION 3,2,3
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS VS_FF_PRERELEASE
FILEOS VOS_NT_WINDOWS32
Expand All @@ -14,12 +14,12 @@ BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "pit-ray\0"
VALUE "FileDescription", "win-vind (32-bit)\0"
VALUE "FileDescription", "win-vind (64-bit)\0"
VALUE "LegalCopyright", "Copyright (c) 2020 pit-ray\0"
VALUE "InternalName", "win-vind (32-bit)\0"
VALUE "InternalName", "win-vind (64-bit)\0"
VALUE "OriginalFilename", "win-vind.exe\0"
VALUE "ProductName", "win-vind (32bit)\0"
VALUE "ProductVersion", "3.2.2\0"
VALUE "ProductName", "win-vind (64bit)\0"
VALUE "ProductVersion", "3.2.3\0"
END
END
BLOCK "VarFileInfo"
Expand Down
2 changes: 0 additions & 2 deletions core/src/common/binded_func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,13 @@ void BindedFunc::register_matcher(
const ModeManager::Mode mode,
const KeyMatcher::shp_t matcher) const
{
if(!matcher) return ;
pimpl->mtrs.at(static_cast<unsigned char>(mode)) = matcher ;
}

void BindedFunc::register_matcher(
const unsigned char mode,
const KeyMatcher::shp_t matcher) const
{
if(!matcher) return ;
pimpl->mtrs.at(mode) = matcher ;
}

Expand Down
2 changes: 1 addition & 1 deletion default_config/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@
"ja": "ウィンドウの高さのリサイズ量"
},
"enable_specific_bindings_in_mygui": {
"value": true,
"value": false,
"en": "Enable specific bindings in Preferences",
"ja": "設定ウィンドウで特殊バインディングを有効化"
}
Expand Down
2 changes: 1 addition & 1 deletion wxgui/include/version.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef _VERSION_HPP
#define _VERSION_HPP

#define WIN_VIND_VERSION "3.2.2"
#define WIN_VIND_VERSION "3.2.3"

#endif
37 changes: 20 additions & 17 deletions wxgui/src/wx_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <array>
#include <fstream>
#include <iomanip>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
Expand Down Expand Up @@ -130,23 +131,33 @@ namespace wxGUI
std::unordered_map<std::string, linkmap_t> mode_links{} ;


nlohmann::json& get_selected_func_json() {
std::size_t get_selected_func_index() {
const auto index = func_list->GetSelection() ;
if(index == wxNOT_FOUND) {
static auto c_empty_obj = nlohmann::json() ;
return c_empty_obj ;
throw RUNTIME_EXCEPT("The function list is not selected.") ;
}
const auto func_label = func_list->GetString(index) ;

for(auto& obj : parser) {
const auto label = obj.at(ioParams::get_vs("ui_lang")).get<std::string>() ;
for(std::size_t i = 0 ; i < parser.size() ; i ++) {
const auto label = parser.at(i).at(ioParams::get_vs("ui_lang")).get<std::string>() ;
if(wxString::FromUTF8(label.c_str()) == func_label) {
return obj ;
return i ;
}
}
throw LOGIC_EXCEPT(func_label + " does not have a valid label.") ;
}

nlohmann::json& get_selected_func_json() {
try {
const auto index = get_selected_func_index() ;
return parser.at(index) ;
}
catch(const std::runtime_error&) {
static auto c_empty_obj = nlohmann::json() ;
return c_empty_obj ;
}
}

const std::string get_selected_func_name() {
auto obj = get_selected_func_json() ;
if(obj.empty()) return std::string() ;
Expand Down Expand Up @@ -595,13 +606,10 @@ namespace wxGUI
const auto str = pimpl->new_cmd->GetLineText(0) ;
if(str.empty()) return ;

const auto index = pimpl->func_list->GetSelection() ;
if(index == wxNOT_FOUND) return ;

try {
const auto mode_idx = pimpl->mode->GetSelection() ;
if(mode_idx != wxNOT_FOUND) {
auto& c = pimpl->parser.at(index).at(g_modes_key[mode_idx]) ;
auto& c = pimpl->get_selected_func_json().at(g_modes_key[mode_idx]) ;
if(!c.contains(str)) {
if(pimpl->cmds->IsEmpty()) {
c.clear() ;
Expand All @@ -624,14 +632,11 @@ namespace wxGUI
const auto index = pimpl->cmds->GetSelection() ;
if(index == wxNOT_FOUND) return ;

const auto func_index = pimpl->func_list->GetSelection() ;
if(func_index == wxNOT_FOUND) return ;

pimpl->cmds->Delete(index) ;
const auto mode_idx = pimpl->mode->GetSelection() ;
if(mode_idx != wxNOT_FOUND) {
try {
pimpl->parser.at(func_index).at(g_modes_key[mode_idx]).erase(index) ;
pimpl->get_selected_func_json().at(g_modes_key[mode_idx]).erase(index) ;
}
catch(const nlohmann::json::exception&){return ;}
}
Expand All @@ -642,13 +647,11 @@ namespace wxGUI
Bind(wxEVT_BUTTON, [this](auto&) {
//read default json (partial)
try {
const auto index = pimpl->func_list->GetSelection() ;
if(index == wxNOT_FOUND) return ;

std::ifstream ifs(Path::to_u8path(Path::Default::BINDINGS())) ;
nlohmann::json p{} ;
ifs >> p ;

const auto index = pimpl->get_selected_func_index() ;
pimpl->parser.at(index).clear() ;
pimpl->parser.at(index) = std::move(p.at(index)) ;

Expand Down

0 comments on commit ec84fa1

Please sign in to comment.