mirror of
https://github.com/hinto-janai/gupax.git
synced 2024-11-17 09:47:36 +00:00
implement [--reset], add [ErrorState] for fullscreen ferris error
This commit is contained in:
parent
6b24a60084
commit
d06cb08940
9 changed files with 158 additions and 232 deletions
BIN
images/ferris/error.png
Normal file
BIN
images/ferris/error.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 64 KiB |
BIN
images/ferris/oops.png
Normal file
BIN
images/ferris/oops.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 71 KiB |
BIN
images/ferris/panic.png
Normal file
BIN
images/ferris/panic.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 47 KiB |
|
@ -1,70 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="1434.979px" height="947px" viewBox="0 0 1434.979 947" enable-background="new 0 0 1434.979 947" xml:space="preserve">
|
||||
<!--<rect fill="#FFFFFF" width="1434.979" height="947"/>-->
|
||||
<path fill="#8F1F1D" d="M712.827,368.579c-131.633,0-251.228,15.825-339.77,41.615v220.298
|
||||
c88.542,25.79,208.137,41.614,339.77,41.614c150.657,0,285.535-20.729,376.134-53.402V421.986
|
||||
C998.361,389.311,863.483,368.579,712.827,368.579"/>
|
||||
<path fill="#8F1F1D" d="M1094.847,567.972c-3.856-10.663-4.629-24.154-1.36-37.162c5.85-23.289,22.421-36.198,37.013-28.833
|
||||
c3.618,1.827,6.773,4.73,9.387,8.418c0.239-0.001,0.479,0,0.715,0.016c0,0,44.552,53.106,3.313,116.003
|
||||
c-0.896,3.569-76.534,91.718-94.043,94.524C1038.411,722.773,1064.762,630.939,1094.847,567.972"/>
|
||||
<path fill="#8F1F1D" d="M363.903,557.551c5.3-9.631,7.158-22.788,4.217-36.426c-5.266-24.416-23.91-41.109-41.642-37.285
|
||||
c-4.398,0.948-8.325,3.072-11.666,6.099c-0.282-0.059-0.564-0.113-0.845-0.153c0,0-56.292,41.952-12.057,113.924
|
||||
c0.805,3.741,83.851,108.838,104.311,115.764C419.612,724.004,394.974,626.947,363.903,557.551"/>
|
||||
<path fill="#E23A26" d="M284.891,563.596l0.007,0.015C285.083,563.755,285.255,563.887,284.891,563.596"/>
|
||||
<path fill="#E33B26" d="M1180.543,488.433c-0.88-3.064-1.756-6.126-2.662-9.162l30.683-44.451c3.13-4.522,3.771-10.398,1.73-15.555
|
||||
c-2.04-5.13-6.49-8.81-11.76-9.71l-51.887-8.805c-2.008-4.102-4.115-8.142-6.229-12.15l21.797-49.903
|
||||
c2.243-5.087,1.769-10.995-1.203-15.608c-2.961-4.636-7.99-7.344-13.349-7.133l-52.656,1.913c-2.727-3.55-5.496-7.068-8.322-10.521
|
||||
l12.102-53.49c1.225-5.433-0.322-11.118-4.104-15.064c-3.762-3.932-9.229-5.559-14.426-4.283l-51.289,12.608
|
||||
c-3.321-2.935-6.699-5.833-10.114-8.673l1.849-54.914c0.197-5.559-2.394-10.842-6.845-13.925
|
||||
c-4.445-3.104-10.093-3.573-14.955-1.266l-47.848,22.747c-3.854-2.21-7.728-4.4-11.644-6.517l-8.455-54.115
|
||||
c-0.857-5.483-4.386-10.139-9.326-12.266c-4.923-2.137-10.568-1.447-14.891,1.808l-42.659,32.007
|
||||
c-4.2-1.395-8.419-2.732-12.692-4.011l-18.386-51.316c-1.87-5.229-6.182-9.071-11.438-10.151c-5.238-1.072-10.63,0.742-14.263,4.802
|
||||
l-35.907,40.171c-4.342-0.5-8.685-0.956-13.043-1.331l-27.723-46.713c-2.811-4.732-7.771-7.612-13.116-7.612
|
||||
c-5.334,0-10.304,2.88-13.09,7.612l-27.733,46.713c-4.358,0.375-8.722,0.831-13.056,1.331l-35.91-40.171
|
||||
c-3.636-4.06-9.047-5.874-14.268-4.802c-5.255,1.092-9.573,4.922-11.433,10.151l-18.402,51.316
|
||||
c-4.26,1.279-8.481,2.627-12.691,4.011l-42.644-32.007c-4.336-3.266-9.98-3.955-14.916-1.808c-4.919,2.127-8.461,6.783-9.313,12.266
|
||||
l-8.461,54.115c-3.914,2.117-7.789,4.294-11.653,6.517L436.1,168.34c-4.858-2.316-10.529-1.838-14.954,1.266
|
||||
c-4.445,3.083-7.042,8.366-6.84,13.925l1.835,54.914c-3.405,2.84-6.774,5.738-10.112,8.673L354.75,234.51
|
||||
c-5.211-1.265-10.67,0.351-14.441,4.283c-3.795,3.946-5.332,9.631-4.113,15.064l12.079,53.49c-2.802,3.467-5.575,6.971-8.293,10.521
|
||||
l-52.655-1.913c-5.314-0.157-10.386,2.497-13.356,7.133c-2.974,4.613-3.425,10.521-1.211,15.608l21.814,49.903
|
||||
c-2.119,4.008-4.224,8.048-6.249,12.15l-51.882,8.805c-5.271,0.888-9.715,4.566-11.765,9.71c-2.037,5.157-1.375,11.033,1.735,15.555
|
||||
l30.69,44.451c-0.236,0.784-0.455,1.576-0.69,2.364l-16.863,17.911l45.341,64.05c0,0,435.152,200.731,838.797,3.396
|
||||
C1169.796,558.719,1180.543,488.433,1180.543,488.433"/>
|
||||
<path d="M795.716,446.557c0,0,48.162-52.734,96.324,0c0,0,37.844,70.318,0,105.473c0,0-61.922,49.223-96.324,0
|
||||
C795.716,552.029,754.434,513.354,795.716,446.557"/>
|
||||
<path fill="#FFFFFF" d="M855.154,481.097c0,19.782-11.66,35.82-26.041,35.82c-14.379,0-26.04-16.038-26.04-35.82
|
||||
c0-19.782,11.661-35.821,26.04-35.821C843.494,445.275,855.154,461.315,855.154,481.097"/>
|
||||
<path d="M578.401,430.129c0,0,84.436-37.385,107.481,46.059c0,0,24.141,97.261-69.339,102.751
|
||||
C616.543,578.939,497.34,555.98,578.401,430.129"/>
|
||||
<rect x="187.424" y="75.529" fill="none" width="1060" height="782"/>
|
||||
<path fill="#FFFFFF" d="M627.514,481.096c0,20.579-12.13,37.27-27.095,37.27c-14.959,0-27.092-16.69-27.092-37.27
|
||||
c0-20.583,12.133-37.27,27.092-37.27C615.384,443.826,627.514,460.513,627.514,481.096"/>
|
||||
<path fill="#E33B26" d="M299.026,574.745c10.967-12.463,37.611-27.557,35.57-46.282c-3.653-33.526-31.456-57.999-62.099-54.658
|
||||
c-7.599,0.827-14.658,3.292-20.923,7.035c-0.463-0.106-0.925-0.211-1.388-0.294c0,0-103.632,50.873-44.564,152.657
|
||||
c0.557,5.137,117.847,155.668,150.787,167.131C377.968,807.836,336.498,671.694,299.026,574.745"/>
|
||||
<path fill="#E33B26" d="M1140.973,570.202c-12.692-10.7-46.162-20.418-46.92-39.238c-1.355-33.697,22.512-62.021,53.312-63.26
|
||||
c7.638-0.308,14.983,1.083,21.734,3.857c0.442-0.174,0.884-0.347,1.329-0.497c0,0,110.025,34.951,66.695,144.366
|
||||
c0.21,5.163-93.468,171.416-124.345,187.635C1092.57,813.681,1118.285,671.635,1140.973,570.202"/>
|
||||
<rect x="187.484" y="75.843" fill="none" width="1059.75" height="781.686"/>
|
||||
<rect x="187.424" y="75.529" fill="none" width="1060" height="782"/>
|
||||
<g>
|
||||
<path fill="#E33B26" d="M283.144,565.511c0,0-137.214-4.942-161.62-140.761l57.596-25.427c0,0-13.912,96.957,106.615,110.022
|
||||
L283.144,565.511"/>
|
||||
<path fill="#E33B26" d="M127.552,333.083c0,0-24.965-49.774-65.807-113.261C18.721,241.035-2.671,299.05,13.482,357.484
|
||||
c17.846,64.558,74.749,105.16,127.097,90.69s80.318-78.535,62.471-143.092c-7.909-28.618-23.501-52.519-42.963-69.011
|
||||
C150.611,287.113,127.552,333.083,127.552,333.083"/>
|
||||
</g>
|
||||
<rect x="187.484" y="75.843" fill="none" width="1059.75" height="781.686"/>
|
||||
<g>
|
||||
<path fill="#E33B26" d="M1148.012,565.511c0,0,137.214-4.942,161.62-140.761l-57.596-25.428c0,0,13.912,96.957-106.615,110.022
|
||||
L1148.012,565.511"/>
|
||||
<path fill="#E33B26" d="M1303.604,333.083c0,0,24.966-49.774,65.808-113.261c43.023,21.212,64.416,79.228,48.262,137.662
|
||||
c-17.846,64.558-74.748,105.16-127.096,90.689c-52.348-14.47-80.318-78.534-62.472-143.091
|
||||
c7.909-28.618,23.501-52.519,42.964-69.011C1280.544,287.113,1303.604,333.083,1303.604,333.083"/>
|
||||
</g>
|
||||
<path d="M807.895,626.942c-7.131-58.735-72.193-61.431-72.193-61.431c-50.936,11.227-59.183,47.369-57.392,75.104L807.895,626.942z"
|
||||
/>
|
||||
</svg>
|
Before Width: | Height: | Size: 6.1 KiB |
|
@ -1,72 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="1259px" height="847px" viewBox="0 0 1259 847" enable-background="new 0 0 1259 847" xml:space="preserve">
|
||||
<!--<rect fill="#FFFFFF" width="1259" height="847"/>-->
|
||||
<path fill="#8F1F1D" d="M706.403,338.05c-131.633,0-251.228,15.825-339.77,41.615v220.298
|
||||
c88.542,25.79,208.137,41.614,339.77,41.614c150.657,0,285.535-20.729,376.134-53.402V391.457
|
||||
C991.938,358.781,857.06,338.05,706.403,338.05"/>
|
||||
<path fill="#8F1F1D" d="M1088.423,537.442c-3.856-10.663-4.629-24.154-1.36-37.162c5.85-23.289,22.421-36.198,37.013-28.833
|
||||
c3.618,1.827,6.773,4.73,9.387,8.418c0.239-0.001,0.479,0,0.715,0.016c0,0,44.552,53.106,3.313,116.003
|
||||
c-0.896,3.569-76.534,91.718-94.043,94.524C1031.987,692.244,1058.338,600.41,1088.423,537.442"/>
|
||||
<path fill="#8F1F1D" d="M357.479,527.021c5.3-9.631,7.158-22.788,4.217-36.426c-5.266-24.416-23.91-41.109-41.642-37.285
|
||||
c-4.398,0.948-8.325,3.072-11.666,6.099c-0.282-0.059-0.564-0.113-0.845-0.153c0,0-56.292,41.952-12.057,113.924
|
||||
c0.805,3.741,83.851,108.838,104.311,115.764C413.188,693.475,388.55,596.418,357.479,527.021"/>
|
||||
<path fill="#E23A26" d="M280.467,535.066l0.007,0.015C280.659,535.226,280.831,535.357,280.467,535.066"/>
|
||||
<path fill="#E33B26" d="M1174.119,457.903c-0.88-3.064-1.756-6.126-2.662-9.162l30.683-44.451c3.13-4.522,3.771-10.398,1.73-15.555
|
||||
c-2.04-5.13-6.49-8.81-11.76-9.71l-51.887-8.805c-2.008-4.102-4.115-8.142-6.229-12.15l21.797-49.903
|
||||
c2.243-5.087,1.769-10.995-1.203-15.608c-2.961-4.636-7.99-7.344-13.349-7.133l-52.656,1.913c-2.727-3.55-5.496-7.068-8.322-10.521
|
||||
l12.102-53.49c1.225-5.433-0.322-11.118-4.104-15.064c-3.762-3.932-9.229-5.559-14.426-4.283l-51.289,12.608
|
||||
c-3.321-2.935-6.699-5.833-10.114-8.673l1.849-54.914c0.197-5.559-2.394-10.842-6.845-13.925
|
||||
c-4.445-3.104-10.093-3.573-14.955-1.266l-47.848,22.747c-3.854-2.21-7.728-4.4-11.644-6.517l-8.455-54.115
|
||||
c-0.857-5.483-4.386-10.139-9.326-12.266c-4.923-2.137-10.568-1.447-14.891,1.808l-42.659,32.007
|
||||
c-4.2-1.395-8.419-2.732-12.692-4.011l-18.386-51.316c-1.87-5.229-6.182-9.071-11.438-10.151c-5.238-1.072-10.63,0.742-14.263,4.802
|
||||
L764.97,100.97c-4.342-0.5-8.685-0.956-13.043-1.331l-27.723-46.713c-2.811-4.732-7.771-7.612-13.116-7.612
|
||||
c-5.334,0-10.304,2.88-13.09,7.612l-27.733,46.713c-4.358,0.375-8.722,0.831-13.056,1.331l-35.91-40.171
|
||||
c-3.636-4.06-9.047-5.874-14.268-4.802c-5.255,1.092-9.573,4.922-11.433,10.151l-18.402,51.316
|
||||
c-4.26,1.279-8.481,2.627-12.691,4.011l-42.644-32.007c-4.336-3.266-9.98-3.955-14.916-1.808c-4.919,2.127-8.461,6.783-9.313,12.266
|
||||
l-8.461,54.115c-3.914,2.117-7.789,4.294-11.653,6.517l-47.842-22.747c-4.858-2.316-10.529-1.838-14.954,1.266
|
||||
c-4.445,3.083-7.042,8.366-6.84,13.925l1.835,54.914c-3.405,2.84-6.774,5.738-10.112,8.673l-51.279-12.608
|
||||
c-5.211-1.265-10.67,0.351-14.441,4.283c-3.795,3.946-5.332,9.631-4.113,15.064l12.079,53.49c-2.802,3.467-5.575,6.971-8.293,10.521
|
||||
l-52.655-1.913c-5.314-0.157-10.386,2.497-13.356,7.133c-2.974,4.613-3.425,10.521-1.211,15.608l21.814,49.903
|
||||
c-2.119,4.008-4.224,8.048-6.249,12.15l-51.882,8.805c-5.271,0.888-9.715,4.566-11.765,9.71c-2.037,5.157-1.375,11.033,1.735,15.555
|
||||
l30.69,44.451c-0.236,0.784-0.455,1.576-0.69,2.364l-16.863,17.911l45.341,64.05c0,0,435.152,200.731,838.797,3.396
|
||||
C1163.372,528.189,1174.119,457.903,1174.119,457.903"/>
|
||||
<path d="M788.629,436.277c0,0,54.108-46.602,95.626,11.5c0,0,29.173,74.328-12.593,104.708c0,0-67.353,41.473-95.627-11.5
|
||||
C776.035,540.985,739.67,497.66,788.629,436.277"/>
|
||||
<path fill="#FFFFFF" d="M843.648,464.356c-2.452,20.385-16.456,35.467-31.276,33.684c-14.817-1.781-24.846-19.755-22.395-40.14
|
||||
c2.452-20.385,16.457-35.468,31.274-33.687C836.071,425.997,846.1,443.971,843.648,464.356"/>
|
||||
<path d="M572.949,399.315c0,0,86.384-26.449,99.021,57.297c0,0,12.086,97.294-79.356,91.705
|
||||
C592.613,548.317,479.508,512.09,572.949,399.315"/>
|
||||
<rect x="181" y="45" fill="none" width="1060" height="782"/>
|
||||
<path fill="#FFFFFF" d="M611.925,441.324c-2.528,21.021-16.969,36.581-32.257,34.742c-15.281-1.837-25.624-20.378-23.095-41.399
|
||||
c2.529-21.026,16.973-36.581,32.253-34.743C604.113,401.763,614.454,420.298,611.925,441.324"/>
|
||||
<path fill="#E33B26" d="M292.602,544.216c10.967-12.463,37.611-27.557,35.57-46.282c-3.653-33.526-31.456-57.999-62.099-54.658
|
||||
c-7.599,0.827-14.658,3.292-20.923,7.035c-0.463-0.106-0.925-0.211-1.388-0.294c0,0-103.632,50.873-44.564,152.657
|
||||
c0.557,5.137,117.847,155.668,150.787,167.131C371.544,777.307,330.074,641.165,292.602,544.216"/>
|
||||
<path fill="#E33B26" d="M1134.549,539.673c-12.692-10.7-46.162-20.418-46.92-39.238c-1.355-33.697,22.512-62.021,53.312-63.26
|
||||
c7.638-0.308,14.983,1.083,21.734,3.857c0.442-0.174,0.884-0.347,1.329-0.497c0,0,110.025,34.951,66.695,144.366
|
||||
c0.21,5.163-93.468,171.416-124.345,187.635C1086.146,783.151,1111.861,641.105,1134.549,539.673"/>
|
||||
<rect x="181.06" y="45.314" fill="none" width="1059.75" height="781.686"/>
|
||||
<path fill="#E33B26" d="M372.142,545.559c0,0-1.383,137.296,133.166,167.933l28.054-56.363c0,0-97.495,9.431-104.995-111.569
|
||||
H372.142"/>
|
||||
<rect x="181" y="45" fill="none" width="1060" height="782"/>
|
||||
<path fill="#E33B26" d="M1057.362,537.246c0,0,1.382,137.296-133.167,167.933l-28.055-56.363c0,0,97.495,9.431,104.995-111.569
|
||||
H1057.362"/>
|
||||
<path fill="#E33B26" d="M960.167,677.279c-20.25-48.941-85.595-68.373-145.951-43.399c-53.126,21.98-84.637,71.031-77.624,115.845
|
||||
c41.946-0.652,86.94-3.371,130.736-9.718c0,0-25.837,41.763-63.857,78.211c25.566,6.599,55.383,4.768,84.076-7.104
|
||||
C947.904,786.141,980.417,726.221,960.167,677.279"/>
|
||||
<path fill="#E33B26" d="M585.746,745.985c0,0,55.203,7.295,130.67,9.155c6.61-47.511-29.38-97.792-86.801-117.242
|
||||
c-63.438-21.488-128.989,2.792-146.414,54.231c-17.425,51.44,19.876,110.561,83.314,132.049
|
||||
c28.121,9.526,56.653,10.049,81.229,3.207C610.833,790.881,585.746,745.985,585.746,745.985"/>
|
||||
<rect x="181.06" y="45.314" fill="none" width="1059.75" height="781.686"/>
|
||||
<g>
|
||||
<path style="stroke:#ffffff;stroke-width:20" d="M92.314,318.146l0.072-12.563c-0.359-24.665,8.95-49.384,31.787-73.989c16.267-18.129,29.512-33.493,30.216-49.411
|
||||
c0.747-16.883-9.835-28.95-33.932-30.499c-15.918-0.704-35.468,4.231-48.394,12.359l-14.075-53.303
|
||||
c18.296-9.34,47.182-17.729,81.429-16.214c63.672,2.816,91.538,39.33,89.768,79.366c-1.621,36.659-25.84,59.753-45.066,79.202
|
||||
c-18.24,19.009-26.789,37.48-27.267,59.207l-0.384,8.683L92.314,318.146z M76.808,384.64c1.152-26.048,19.789-43.105,44.872-41.997
|
||||
c26.047,1.152,42.14,19.746,41.471,45.815c-1.109,25.083-18.824,43.148-45.353,41.975C92.232,429.303,75.698,409.723,76.808,384.64
|
||||
z"/>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 6.6 KiB |
48
src/about.rs
48
src/about.rs
|
@ -1,48 +0,0 @@
|
|||
// Gupax - GUI Uniting P2Pool And XMRig
|
||||
//
|
||||
// Copyright (c) 2022 hinto-janaiyo
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::App;
|
||||
use egui::special_emojis::GITHUB;
|
||||
|
||||
// Main data structure for the About tab
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct About {
|
||||
}
|
||||
|
||||
impl About {
|
||||
pub fn show(app: &mut App, width: f32, height: f32, ctx: &egui::Context, ui: &mut egui::Ui) {
|
||||
ui.add_space(10.0);
|
||||
ui.vertical_centered(|ui| {
|
||||
let space = ui.available_height()/2.2;
|
||||
app.banner.show(ui);
|
||||
ui.label("Gupax (guh-picks) is a cross-platform GUI for mining");
|
||||
ui.hyperlink_to("[Monero]", "https://www.github.com/monero-project/monero");
|
||||
ui.label("on the decentralized");
|
||||
ui.hyperlink_to("[P2Pool]", "https://www.github.com/SChernykh/p2pool");
|
||||
ui.label("using the dedicated");
|
||||
ui.hyperlink_to("[XMRig]", "https://www.github.com/xmrig/xmrig");
|
||||
ui.label("miner for max hashrate");
|
||||
|
||||
ui.add_space(ui.available_height()/2.4);
|
||||
|
||||
ui.hyperlink_to("Powered by egui", "https://github.com/emilk/egui");
|
||||
ui.hyperlink_to(format!("{} {}", GITHUB, "Gupax made by hinto-janaiyo"), "https://www.github.com/hinto-janaiyo/gupax");
|
||||
ui.label("egui is licensed under MIT & Apache-2.0");
|
||||
ui.label("Gupax, P2Pool, and XMRig are licensed under GPLv3");
|
||||
});
|
||||
}
|
||||
}
|
|
@ -205,7 +205,6 @@ impl State {
|
|||
info!("State | Creating new default...");
|
||||
let new = Self::new();
|
||||
let path = get_file_path(File::State)?;
|
||||
println!("{:#?}", new);
|
||||
let string = match toml::ser::to_string(&new) {
|
||||
Ok(o) => { info!("State | Serialization ... OK"); o },
|
||||
Err(e) => { error!("State | Couldn't serialize default file: {}", e); return Err(TomlError::Serialize(e)) },
|
||||
|
|
File diff suppressed because one or more lines are too long
160
src/main.rs
160
src/main.rs
|
@ -50,13 +50,12 @@ mod ferris;
|
|||
mod constants;
|
||||
mod node;
|
||||
mod disk;
|
||||
mod about;
|
||||
mod status;
|
||||
mod gupax;
|
||||
mod p2pool;
|
||||
mod xmrig;
|
||||
mod update;
|
||||
use {ferris::*,constants::*,node::*,disk::*,about::*,status::*,gupax::*,p2pool::*,xmrig::*,update::*};
|
||||
use {ferris::*,constants::*,node::*,disk::*,status::*,gupax::*,p2pool::*,xmrig::*,update::*};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- Struct + Impl
|
||||
// The state of the outer main [App].
|
||||
|
@ -74,8 +73,14 @@ pub struct App {
|
|||
og: Arc<Mutex<State>>, // og = Old state to compare against
|
||||
state: State, // state = Working state (current settings)
|
||||
update: Arc<Mutex<Update>>, // State for update data [update.rs]
|
||||
og_node_vec: Vec<(String, Node)>, // Manual Node database
|
||||
node_vec: Vec<(String, Node)>, // Manual Node database
|
||||
diff: bool, // This bool indicates state changes
|
||||
// Error State
|
||||
// These values are essentially global variables that
|
||||
// indicate if an error message needs to be displayed
|
||||
// (it takes up the whole screen with [error_msg] and buttons for ok/quit/etc)
|
||||
error_state: ErrorState,
|
||||
// Process/update state:
|
||||
// Doesn't make sense to save this on disk
|
||||
// so it's represented as a bool here.
|
||||
|
@ -92,7 +97,7 @@ pub struct App {
|
|||
os: &'static str, // OS
|
||||
version: &'static str, // Gupax version
|
||||
name_version: String, // [Gupax vX.X.X]
|
||||
banner: RetainedImage, // Gupax banner image
|
||||
image: Images, // Custom Struct holding pre-compiled bytes of [Images]
|
||||
regex: Regexes, // Custom Struct holding pre-made [Regex]'s
|
||||
}
|
||||
|
||||
|
@ -117,8 +122,10 @@ impl App {
|
|||
og: Arc::new(Mutex::new(State::new())),
|
||||
state: State::new(),
|
||||
update: Arc::new(Mutex::new(Update::new(String::new(), PathBuf::new(), PathBuf::new(), true))),
|
||||
og_node_vec: Node::new_vec(),
|
||||
node_vec: Node::new_vec(),
|
||||
diff: false,
|
||||
error_state: ErrorState::new(),
|
||||
p2pool: false,
|
||||
xmrig: false,
|
||||
no_startup: false,
|
||||
|
@ -130,7 +137,7 @@ impl App {
|
|||
os: OS,
|
||||
version: GUPAX_VERSION,
|
||||
name_version: format!("Gupax {}", GUPAX_VERSION),
|
||||
banner: RetainedImage::from_image_bytes("banner.png", BYTES_BANNER).unwrap(),
|
||||
image: Images::new(),
|
||||
regex: Regexes::new(),
|
||||
};
|
||||
// Apply arg state
|
||||
|
@ -188,6 +195,58 @@ impl Default for Tab {
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- [ErrorState] struct
|
||||
pub struct ErrorState {
|
||||
error: bool, // Is there an error?
|
||||
msg: String, // What message to display?
|
||||
image: RetainedImage, // Which ferris to display?
|
||||
buttons: ErrorButtons, // Which buttons to display?
|
||||
}
|
||||
|
||||
impl ErrorState {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
error: false,
|
||||
msg: String::new(),
|
||||
image: RetainedImage::from_image_bytes("banner.png", FERRIS_ERROR).unwrap(),
|
||||
buttons: ErrorButtons::Okay,
|
||||
}
|
||||
}
|
||||
|
||||
// Convenience function to set the [App] error state
|
||||
pub fn set(mut self, new: Self) {
|
||||
self = new;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- [ErrorButtons] enum
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
enum ErrorButtons {
|
||||
YesNo,
|
||||
YesQuit,
|
||||
Okay,
|
||||
Quit,
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- [Images] struct
|
||||
struct Images {
|
||||
banner: RetainedImage,
|
||||
oops: RetainedImage,
|
||||
error: RetainedImage,
|
||||
panic: RetainedImage,
|
||||
}
|
||||
|
||||
impl Images {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
banner: RetainedImage::from_image_bytes("banner.png", BYTES_BANNER).unwrap(),
|
||||
oops: RetainedImage::from_image_bytes("banner.png", FERRIS_OOPS).unwrap(),
|
||||
error: RetainedImage::from_image_bytes("banner.png", FERRIS_ERROR).unwrap(),
|
||||
panic: RetainedImage::from_image_bytes("banner.png", FERRIS_PANIC).unwrap(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- [Regexes] struct
|
||||
#[derive(Clone, Debug)]
|
||||
struct Regexes {
|
||||
|
@ -223,6 +282,7 @@ fn init_text_styles(ctx: &egui::Context, width: f32) {
|
|||
(Name("Tab".into()), FontId::new(scale*1.2, Proportional)),
|
||||
(Name("Bottom".into()), FontId::new(scale/2.0, Proportional)),
|
||||
(Name("MonospaceSmall".into()), FontId::new(scale/2.5, egui::FontFamily::Monospace)),
|
||||
(Name("MonospaceLarge".into()), FontId::new(scale/1.5, egui::FontFamily::Monospace)),
|
||||
].into();
|
||||
// style.visuals.selection.stroke = Stroke { width: 5.0, color: Color32::from_rgb(255, 255, 255) };
|
||||
// style.spacing.slider_width = scale;
|
||||
|
@ -347,6 +407,25 @@ fn init_auto(app: &App) {
|
|||
}
|
||||
}
|
||||
|
||||
fn reset() {
|
||||
let mut code = 0;
|
||||
info!("Resetting [state.toml]...");
|
||||
match State::create_new() {
|
||||
Ok(_) => info!("Resetting [state.toml] ... OK"),
|
||||
Err(e) => { error!("Resetting [state.toml] ... FAIL ... {}", e); code = 1; },
|
||||
}
|
||||
info!("Resetting [node.toml]...");
|
||||
match Node::create_new() {
|
||||
Ok(_) => info!("Resetting [node.toml] ... OK"),
|
||||
Err(e) => { error!("Resetting [node.toml] ... FAIL ... {}", e); code = 1; },
|
||||
}
|
||||
match code {
|
||||
0 => println!("\nGupax files were reset successfully."),
|
||||
_ => println!("\nGupax files reset FAILED."),
|
||||
}
|
||||
exit(code);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- Misc functions
|
||||
fn parse_args(mut app: App) -> App {
|
||||
info!("Parsing CLI arguments...");
|
||||
|
@ -360,7 +439,7 @@ fn parse_args(mut app: App) -> App {
|
|||
println!("Gupax {} [OS: {}, Commit: {}]\n\n{}", GUPAX_VERSION, OS_NAME, &COMMIT[..40], ARG_COPYRIGHT);
|
||||
exit(0);
|
||||
},
|
||||
"-f"|"--ferris" => { println!("{}", FERRIS); exit(0); },
|
||||
"-f"|"--ferris" => { println!("{}", FERRIS_ANSI); exit(0); },
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
@ -369,8 +448,8 @@ fn parse_args(mut app: App) -> App {
|
|||
match arg.as_str() {
|
||||
"-l"|"--node-list" => { info!("Printing node list..."); print_disk_file(File::Node); }
|
||||
"-s"|"--state" => { info!("Printing state..."); print_disk_file(File::State); }
|
||||
"-n"|"--no-startup" => { info!("Disabling startup..."); app.no_startup = true; }
|
||||
"-r"|"--reset" => { info!("Resetting state..."); app.reset = true; }
|
||||
"-r"|"--reset" => { reset(); }
|
||||
"-n"|"--no-startup" => { app.no_startup = true; }
|
||||
_ => { eprintln!("[Gupax error] Invalid option: [{}]\nFor help, use: [--help]", arg); exit(1); },
|
||||
}
|
||||
}
|
||||
|
@ -517,21 +596,52 @@ impl eframe::App for App {
|
|||
frame.set_fullscreen(!info.window_info.fullscreen);
|
||||
}
|
||||
|
||||
// If no state diff (og == state), compare and enable if found.
|
||||
// The struct fields are compared directly because [Version]
|
||||
// contains Arc<Mutex>'s that cannot be compared easily.
|
||||
// They don't need to be compared anyway.
|
||||
let og = self.og.lock().unwrap().clone();
|
||||
// If there's an error, display [ErrorState] on the whole screen until user responds
|
||||
if self.error_state.error {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.vertical_centered(|ui| {
|
||||
// Set width/height/font
|
||||
let width = self.width;
|
||||
let height = self.height/4.0;
|
||||
ui.style_mut().override_text_style = Some(Name("MonospaceLarge".into()));
|
||||
self.error_state.image.show_max_size(ui, Vec2::new(width, height));
|
||||
|
||||
ui.add_sized([width, height], Label::new("--- Gupax has encountered an error ---"));
|
||||
ui.add_sized([width, height], Label::new(&self.error_state.msg));
|
||||
use ErrorButtons::*;
|
||||
let height = ui.available_height();
|
||||
match self.error_state.buttons {
|
||||
YesNo => {
|
||||
if ui.add_sized([width, height/2.0], egui::Button::new("Yes")).clicked() { self.error_state = ErrorState::new(); }
|
||||
if ui.add_sized([width, height/2.0], egui::Button::new("No")).clicked() { exit(1); }
|
||||
},
|
||||
YesQuit => {
|
||||
if ui.add_sized([width, height/2.0], egui::Button::new("Okay")).clicked() { self.error_state = ErrorState::new(); }
|
||||
if ui.add_sized([width, height/2.0], egui::Button::new("Quit")).clicked() { exit(1); }
|
||||
},
|
||||
Okay => if ui.add_sized([width, height], egui::Button::new("Okay")).clicked() { self.error_state = ErrorState::new(); },
|
||||
Quit => if ui.add_sized([width, height], egui::Button::new("Quit")).clicked() { exit(1); },
|
||||
}
|
||||
})});
|
||||
return
|
||||
}
|
||||
|
||||
// The [P2Pool Node] selection needs to be the same
|
||||
// for both [State] and [Og] because of [Auto-select]
|
||||
// Wrapping [node] within an [Arc<Mutex>] is a lot more work
|
||||
// so sending it into the [Ping] thread is not viable.
|
||||
self.state.p2pool.node = self.og.lock().unwrap().p2pool.node;
|
||||
if og.gupax != self.state.gupax || og.p2pool != self.state.p2pool || og.xmrig != self.state.xmrig {
|
||||
// Compare [og == state] and the [node_vec] and enable diff if found.
|
||||
// The struct fields are compared directly because [Version]
|
||||
// contains Arc<Mutex>'s that cannot be compared easily.
|
||||
// They don't need to be compared anyway.
|
||||
let og = self.og.lock().unwrap();
|
||||
if og.gupax != self.state.gupax || og.p2pool != self.state.p2pool || og.xmrig != self.state.xmrig || self.og_node_vec != self.node_vec {
|
||||
self.diff = true;
|
||||
} else {
|
||||
self.diff = false;
|
||||
}
|
||||
drop(og);
|
||||
|
||||
// Close confirmation.
|
||||
if self.quit {
|
||||
|
@ -661,20 +771,22 @@ impl eframe::App for App {
|
|||
// [Start/Stop/Restart] + [Simple/Advanced] + [Save/Reset]
|
||||
let width = (ui.available_width()/3.0)-(SPACE*3.0);
|
||||
ui.group(|ui| {
|
||||
if self.diff == false {
|
||||
ui.set_enabled(false)
|
||||
}
|
||||
ui.set_enabled(self.diff);
|
||||
let width = width / 2.0;
|
||||
if ui.add_sized([width, height], egui::Button::new("Reset")).on_hover_text("Reset changes").clicked() {
|
||||
self.state.gupax = self.og.lock().unwrap().gupax.clone();
|
||||
self.state.p2pool = self.og.lock().unwrap().p2pool.clone();
|
||||
self.state.xmrig = self.og.lock().unwrap().xmrig.clone();
|
||||
let og = self.og.lock().unwrap().clone();
|
||||
self.state.gupax = og.gupax;
|
||||
self.state.p2pool = og.p2pool;
|
||||
self.state.xmrig = og.xmrig;
|
||||
self.node_vec = self.og_node_vec.clone();
|
||||
}
|
||||
if ui.add_sized([width, height], egui::Button::new("Save")).on_hover_text("Save changes").clicked() {
|
||||
self.og.lock().unwrap().gupax = self.state.gupax.clone();
|
||||
self.og.lock().unwrap().p2pool = self.state.p2pool.clone();
|
||||
self.og.lock().unwrap().xmrig = self.state.xmrig.clone();
|
||||
self.og.lock().unwrap().save();
|
||||
let mut og = self.og.lock().unwrap();
|
||||
og.gupax = self.state.gupax.clone();
|
||||
og.p2pool = self.state.p2pool.clone();
|
||||
og.xmrig = self.state.xmrig.clone();
|
||||
self.state.save();
|
||||
self.og_node_vec = self.node_vec.clone();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -752,7 +864,7 @@ impl eframe::App for App {
|
|||
ui.add_space(10.0);
|
||||
ui.vertical_centered(|ui| {
|
||||
// Display [Gupax] banner at max, 1/4 the available length
|
||||
self.banner.show_max_size(ui, Vec2::new(self.width, self.height/4.0));
|
||||
self.image.banner.show_max_size(ui, Vec2::new(self.width, self.height/4.0));
|
||||
ui.label("Gupax is a cross-platform GUI for mining");
|
||||
ui.hyperlink_to("[Monero]", "https://www.github.com/monero-project/monero");
|
||||
ui.label("on the decentralized");
|
||||
|
|
Loading…
Reference in a new issue