Add MineSweeper

This commit is contained in:
daleclack 2022-11-06 22:43:04 +08:00
parent 72ee74fe5c
commit b07ccc9bf1
6 changed files with 400 additions and 5 deletions

View File

@ -105,7 +105,9 @@ set(RESOURCE_LIST
icons/scalable/status/line.svg
icons/scalable/status/rectangle.svg
icons/scalable/status/calcapp.svg
icons/scalable/status/calcapp_running.svg)
icons/scalable/status/calcapp_running.svg
icons/scalable/status/mines_app.svg
icons/scalable/status/mines_app_running.svg)
compile_gresources(RESOURCE_FILE
XML_OUT

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="128" height="128" version="1.0"><defs><linearGradient id="a"><stop offset="0" stop-color="#68676b"/><stop offset=".8" stop-color="#424048"/><stop offset="1" stop-color="#241f31"/></linearGradient><radialGradient xlink:href="#a" id="d" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1.34416 .0006 -.00062 1.38763 -121.22 -718.103)" cx="279.422" cy="446.483" fx="279.422" fy="446.483" r="224"/><linearGradient xlink:href="#b" id="e" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1.0015 0 0 .99993 72.09 56.015)" x1="43.844" y1="234" x2="-60" y2="234"/><linearGradient id="b"><stop offset="0" stop-color="#d5d3cf"/><stop offset=".038" stop-color="#e3e2df"/><stop offset=".077" stop-color="#c0bfbc"/><stop offset=".923" stop-color="#c0bfbc"/><stop offset=".962" stop-color="#e3e2df"/><stop offset="1" stop-color="#d5d3cf"/></linearGradient></defs><g transform="translate(0 -172)"><g transform="matrix(1.34135 0 0 1.34135 -87.385 -639.02)"><rect ry="32" rx="32" y="-100" x="112" height="288" width="288" id="c" style="marker:none" display="inline" opacity="1" vector-effect="none" fill="#241f31" fill-opacity="1" stroke="none" stroke-width="32" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="4" stroke-dasharray="none" stroke-dashoffset="0" stroke-opacity="1" marker-start="none" marker-mid="none" marker-end="none" paint-order="normal"/><use transform="rotate(45 256 44)" xlink:href="#c" width="100%" height="100%" style="marker:none" fill="#241f31" stroke-width="32"/><circle r="168" cy="44" cx="256" style="marker:none" fill="url(#d)"/></g><rect ry="8" rx="8" height="48" width="104" x="12" y="240" fill="url(#e)"/><path d="M62 218v66h46c4.432 0 8-3.568 8-8v-50c0-4.432-3.568-8-8-8H62z" fill="#deddda"/><path d="M20 182c-4.432 0-8 3.568-8 8v84c0 4.432 3.568 8 8 8h44v-50h52v-42c0-4.432-3.568-8-8-8H66v2h-4v-2z" fill="#f6f5f4"/><path d="M12 232h104" fill="none" stroke="#deddda" stroke-width="4"/><path d="M12 231h104" fill="none" stroke="#c0bfbc" stroke-width="2"/><path d="M64 184v100" fill="none" stroke="#deddda" stroke-width="4"/><path d="M28 189.57v32.454h4.103V209.72L50 200.943z" fill="#2dc0af"/><path style="line-height:1000%;-inkscape-font-specification:'Cantarell Ultra-Bold'" d="M28 270h18v-6h-6v-20h-3.196l-10.069 5.225 2.193 5.206L34 252l-.02 12H28z" font-weight="800" font-family="Cantarell" letter-spacing="0" word-spacing="0" fill="#1a5fb4"/><g transform="translate(-2 1)" fill="#a51d2d"><circle style="marker:none" cx="91" cy="257" r="15"/><rect style="marker:none" width="6" height="38" x="88" y="238" rx="2" ry="2"/><rect ry="2" rx="2" y="-110" x="254" height="38" width="6" style="marker:none" transform="rotate(90)"/><rect ry="2" rx="2" y="98.38" x="243.073" height="38" width="6" style="marker:none" transform="rotate(45)"/><rect transform="rotate(135)" style="marker:none" width="6" height="38" x="114.38" y="-265.073" rx="2" ry="2"/></g><g transform="translate(-2 -1)" fill="#ed333b"><circle r="15" cy="257" cx="91" style="marker:none"/><rect ry="2" rx="2" y="238" x="88" height="38" width="6" style="marker:none"/><rect transform="rotate(90)" style="marker:none" width="6" height="38" x="254" y="-110" rx="2" ry="2"/><rect transform="rotate(45)" style="marker:none" width="6" height="38" x="243.073" y="98.38" rx="2" ry="2"/><rect ry="2" rx="2" y="-265.073" x="114.38" height="38" width="6" style="marker:none" transform="rotate(135)"/></g></g></svg>

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -0,0 +1,302 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="128"
height="128"
version="1.0"
id="svg75"
sodipodi:docname="mines_app_running.svg"
inkscape:version="1.2.1 (9c6d41e410, 2022-07-14, custom)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview77"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
showgrid="false"
inkscape:zoom="6.609375"
inkscape:cx="64.07565"
inkscape:cy="64"
inkscape:window-width="1856"
inkscape:window-height="1048"
inkscape:window-x="64"
inkscape:window-y="32"
inkscape:window-maximized="1"
inkscape:current-layer="svg75" />
<defs
id="defs24">
<linearGradient
id="a">
<stop
offset="0"
stop-color="#68676b"
id="stop2" />
<stop
offset=".8"
stop-color="#424048"
id="stop4" />
<stop
offset="1"
stop-color="#241f31"
id="stop6" />
</linearGradient>
<radialGradient
xlink:href="#a"
id="d"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.34416 .0006 -.00062 1.38763 -121.22 -718.103)"
cx="279.422"
cy="446.483"
fx="279.422"
fy="446.483"
r="224" />
<linearGradient
xlink:href="#b"
id="e"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.0015 0 0 .99993 72.09 56.015)"
x1="43.844"
y1="234"
x2="-60"
y2="234" />
<linearGradient
id="b">
<stop
offset="0"
stop-color="#d5d3cf"
id="stop11" />
<stop
offset=".038"
stop-color="#e3e2df"
id="stop13" />
<stop
offset=".077"
stop-color="#c0bfbc"
id="stop15" />
<stop
offset=".923"
stop-color="#c0bfbc"
id="stop17" />
<stop
offset=".962"
stop-color="#e3e2df"
id="stop19" />
<stop
offset="1"
stop-color="#d5d3cf"
id="stop21" />
</linearGradient>
</defs>
<g
transform="translate(0 -172)"
id="g73">
<g
transform="matrix(1.34135 0 0 1.34135 -87.385 -639.02)"
id="g31">
<rect
ry="32"
rx="32"
y="-100"
x="112"
height="288"
width="288"
id="c"
style="marker:none"
display="inline"
opacity="1"
vector-effect="none"
fill="#241f31"
fill-opacity="1"
stroke="none"
stroke-width="32"
stroke-linecap="butt"
stroke-linejoin="miter"
stroke-miterlimit="4"
stroke-dasharray="none"
stroke-dashoffset="0"
stroke-opacity="1"
marker-start="none"
marker-mid="none"
marker-end="none"
paint-order="normal" />
<use
transform="rotate(45 256 44)"
xlink:href="#c"
width="100%"
height="100%"
style="marker:none"
fill="#241f31"
stroke-width="32"
id="use27" />
<circle
r="168"
cy="44"
cx="256"
style="marker:none"
fill="url(#d)"
id="circle29" />
</g>
<rect
ry="8"
rx="8"
height="48"
width="104"
x="12"
y="240"
fill="url(#e)"
id="rect33" />
<path
d="M62 218v66h46c4.432 0 8-3.568 8-8v-50c0-4.432-3.568-8-8-8H62z"
fill="#deddda"
id="path35" />
<path
d="M20 182c-4.432 0-8 3.568-8 8v84c0 4.432 3.568 8 8 8h44v-50h52v-42c0-4.432-3.568-8-8-8H66v2h-4v-2z"
fill="#f6f5f4"
id="path37" />
<path
d="M12 232h104"
fill="none"
stroke="#deddda"
stroke-width="4"
id="path39" />
<path
d="M12 231h104"
fill="none"
stroke="#c0bfbc"
stroke-width="2"
id="path41" />
<path
d="M64 184v100"
fill="none"
stroke="#deddda"
stroke-width="4"
id="path43" />
<path
d="M28 189.57v32.454h4.103V209.72L50 200.943z"
fill="#2dc0af"
id="path45" />
<path
style="line-height:1000%;-inkscape-font-specification:'Cantarell Ultra-Bold'"
d="M28 270h18v-6h-6v-20h-3.196l-10.069 5.225 2.193 5.206L34 252l-.02 12H28z"
font-weight="800"
font-family="Cantarell"
letter-spacing="0"
word-spacing="0"
fill="#1a5fb4"
id="path47" />
<g
transform="translate(-2 1)"
fill="#a51d2d"
id="g59">
<circle
style="marker:none"
cx="91"
cy="257"
r="15"
id="circle49" />
<rect
style="marker:none"
width="6"
height="38"
x="88"
y="238"
rx="2"
ry="2"
id="rect51" />
<rect
ry="2"
rx="2"
y="-110"
x="254"
height="38"
width="6"
style="marker:none"
transform="rotate(90)"
id="rect53" />
<rect
ry="2"
rx="2"
y="98.38"
x="243.073"
height="38"
width="6"
style="marker:none"
transform="rotate(45)"
id="rect55" />
<rect
transform="rotate(135)"
style="marker:none"
width="6"
height="38"
x="114.38"
y="-265.073"
rx="2"
ry="2"
id="rect57" />
</g>
<g
transform="translate(-2 -1)"
fill="#ed333b"
id="g71">
<circle
r="15"
cy="257"
cx="91"
style="marker:none"
id="circle61" />
<rect
ry="2"
rx="2"
y="238"
x="88"
height="38"
width="6"
style="marker:none"
id="rect63" />
<rect
transform="rotate(90)"
style="marker:none"
width="6"
height="38"
x="254"
y="-110"
rx="2"
ry="2"
id="rect65" />
<rect
transform="rotate(45)"
style="marker:none"
width="6"
height="38"
x="243.073"
y="98.38"
rx="2"
ry="2"
id="rect67" />
<rect
ry="2"
rx="2"
y="-265.073"
x="114.38"
height="38"
width="6"
style="marker:none"
transform="rotate(135)"
id="rect69" />
</g>
</g>
<rect
style="fill:#0000ff"
id="rect235"
width="5.3330002"
height="128"
x="0.36789855"
y="0.029102948" />
</svg>

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<!-- Generated with glade 3.40.0 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<object class="GtkImage" id="image1">
@ -116,6 +116,18 @@
<property name="pixel-size">48</property>
<property name="icon-name">calcapp</property>
</object>
<object class="GtkImage" id="image26">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">mines_app</property>
<property name="icon_size">6</property>
</object>
<object class="GtkImage" id="image27">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">mines_app</property>
<property name="icon_size">6</property>
</object>
<object class="GtkImage" id="image3">
<property name="visible">True</property>
<property name="can-focus">False</property>
@ -370,6 +382,21 @@
<property name="position">7</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btnmine">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image26</property>
<property name="relief">none</property>
<property name="always-show-image">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">8</property>
</packing>
</child>
<child>
<placeholder/>
</child>
@ -760,7 +787,20 @@
</packing>
</child>
<child>
<placeholder/>
<object class="GtkButton" id="padmine">
<property name="label" translatable="yes">MineSweeper</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image27</property>
<property name="relief">none</property>
<property name="image-position">top</property>
<property name="always-show-image">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<placeholder/>

View File

@ -18,6 +18,7 @@ MyDock::MyDock(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &ref_Gl
ref_builder->get_widget("btnset", btnset);
ref_builder->get_widget("btngame24",btngame24);
ref_builder->get_widget("btncalc",btncalc);
ref_builder->get_widget("btnmine", btnmine);
ref_builder->get_widget("separator_start", separator_start);
ref_builder->get_widget("separator_end", separator_end);
ref_builder->get_widget("launchpad_stack", launchpad_stack);
@ -39,6 +40,7 @@ MyDock::MyDock(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &ref_Gl
ref_builder->get_widget("padrun", padrun);
ref_builder->get_widget("padgame24",padgame24);
ref_builder->get_widget("padcalc",padcalc);
ref_builder->get_widget("padmine", padmine);
// Create window
game_win = Game::create();
@ -46,6 +48,8 @@ MyDock::MyDock(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &ref_Gl
calc_win = CalcApp::create();
// Link signals
// These signal handlers not contain a icon on the dock
btnlaunch->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::btnlaunch_clicked));
padaud->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padaud_clicked));
padgedit->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padgedit_clicked));
@ -54,6 +58,13 @@ MyDock::MyDock(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &ref_Gl
padvlc_win32->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padvlc_win32_clicked));
padrun->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::btnrun_clicked));
/*
These functions contain a icon on the dock
the first signal for control button on dock
the next signal for button on launchpad
last 1 or 2 signals for the window
*/
btnset->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::btnset_clicked));
padset->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padset_clicked));
prefs_win.signal_delete_event().connect(sigc::mem_fun(*this, &MyDock::prefs_win_closed));
@ -90,6 +101,10 @@ MyDock::MyDock(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &ref_Gl
padedit->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padedit_clicked));
editor_win.signal_delete_event().connect(sigc::mem_fun(*this, &MyDock::editor_win_closed));
btnmine->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::btnmine_clicked));
padmine->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padmine_clicked));
mine_win.signal_delete_event().connect(sigc::mem_fun(*this, &MyDock::mine_win_closed));
// Add Finder
finder_box->pack_start(finder);
@ -116,11 +131,13 @@ void MyDock::set_dock_mode(DockMode mode){
}
}
// Set the style of dock widget
void MyDock::apply_style(Gtk::Widget &widget){
auto style = widget.get_style_context();
style->add_provider(provider,G_MAXUINT);
}
// Launchpad
void MyDock::btnlaunch_clicked()
{
if (launchpad_shown)
@ -143,6 +160,13 @@ void MyDock::mydock_init(Gtk::Window *window, Gtk::Image *background1)
parent_win = window;
}
/*
Functions for execute outside apps
padxx_clicked() for click in launchpad
The first three functions for use in linux
and the next three functions for windows
*/
void MyDock::padaud_clicked()
{
// Start audacious app
@ -375,6 +399,25 @@ void MyDock::padedit_clicked()
btnlaunch_clicked();
}
// Signal Handler for minesweeper window
bool MyDock::mine_win_closed(GdkEventAny *event){
btnmine->set_image_from_icon_name("mines_app", Gtk::ICON_SIZE_DIALOG);
mine_win.hide();
return true;
}
void MyDock::btnmine_clicked(){
btnmine->set_image_from_icon_name("mines_app_running", Gtk::ICON_SIZE_DIALOG);
window_ctrl(mine_win);
}
void MyDock::padmine_clicked(){
btnmine->set_image_from_icon_name("mines_app_running", Gtk::ICON_SIZE_DIALOG);
window_ctrl(mine_win, false);
btnlaunch_clicked();
}
// Signal Handler for run window
void MyDock::btnrun_clicked()

View File

@ -11,6 +11,7 @@
#include "TextEditor.hh"
#include "Game24Win.hh"
#include "CalcApp.hh"
#include "MineSweeper.hh"
enum class DockMode{
MODE_DOCK,
@ -30,7 +31,7 @@ private:
// Child widgets
Gtk::Box *finder_box, *dock_box;
Gtk::Button *btnlaunch, *btndraw, *btnfiles, *btncalc,
*btngame, *btnedit, *btnimage, *btnset, *btngame24;
*btngame, *btnedit, *btnimage, *btnset, *btngame24, *btnmine;
Gtk::Separator *separator_start, *separator_end;
// Finder
@ -41,7 +42,7 @@ private:
Gtk::Stack *launchpad_stack;
Gtk::Grid *default_page, *launchpad_page, *apps_grid;
Gtk::Button *padaud, *paddraw, *padfile, *padgedit, *padgame, *padset, *padcalc,
*padimage, *padnote, *padedit, *padvlc, *padvlc_win32, *padrun, *padgame24;
*padimage, *padnote, *padedit, *padvlc, *padvlc_win32, *padrun, *padgame24, *padmine;
Gtk::Label label1;
// Window Preferences
@ -95,6 +96,12 @@ private:
void btnedit_clicked();
void padedit_clicked();
// MineSweeper
MineSweeper mine_win;
bool mine_win_closed(GdkEventAny *event);
void btnmine_clicked();
void padmine_clicked();
// A Simple Runner
GtkRunner runner1;