Add files via upload

This commit is contained in:
Evan Su 2021-10-26 22:53:00 -04:00 committed by GitHub
parent b8f0414f9a
commit 232827ca0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 15 deletions

View File

@ -59,7 +59,7 @@ import (
"golang.org/x/crypto/sha3" "golang.org/x/crypto/sha3"
// UI // UI
"github.com/AllenDang/giu" "github.com/AllenDang/giu" // eff40f64dad5eed8e2b6faca5059705876ca7e12
// Reed-Solomon // Reed-Solomon
"github.com/HACKERALERT/infectious" "github.com/HACKERALERT/infectious"
@ -101,6 +101,8 @@ var languageSelected int32
// Generic variables // Generic variables
var version = "v1.20" var version = "v1.20"
var window *giu.MasterWindow
var windowOptimized bool
var dpi float32 var dpi float32
var tab = 0 var tab = 0
var mode string var mode string
@ -223,7 +225,8 @@ var shredTotal float32
var shredOverlay string var shredOverlay string
func draw() { func draw() {
giu.SingleWindow().Layout( giu.SingleWindow().Flags(giu.WindowFlagsNoDecoration|giu.WindowFlagsNoNav|
giu.WindowFlagsNoMove|giu.WindowFlagsNoScrollWithMouse).Layout(
giu.Custom(func() { giu.Custom(func() {
pos := giu.GetCursorPos() pos := giu.GetCursorPos()
w, _ := giu.CalcTextSize(languages[languageSelected]) w, _ := giu.CalcTextSize(languages[languageSelected])
@ -361,7 +364,7 @@ func draw() {
giu.Custom(func() { giu.Custom(func() {
if showProgress { if showProgress {
giu.PopupModal(" "). giu.PopupModal(" ").
Flags(giu.WindowFlagsNoMove|giu.WindowFlagsNoResize|giu.WindowFlagsNoTitleBar).Layout( Flags(giu.WindowFlagsNoMove|giu.WindowFlagsNoResize).Layout(
giu.Custom(func() { giu.Custom(func() {
if !working { if !working {
giu.CloseCurrentPopup() giu.CloseCurrentPopup()
@ -383,12 +386,10 @@ func draw() {
giu.Row( giu.Row(
giu.Label(inputLabel), giu.Label(inputLabel),
giu.Custom(func() { giu.Custom(func() {
w, _ := giu.GetAvailableRegion()
bw, _ := giu.CalcTextSize(s("Clear")) bw, _ := giu.CalcTextSize(s("Clear"))
p, _ := giu.GetWindowPadding() p, _ := giu.GetWindowPadding()
bw += p * 2 bw += p * 2
dw := w - bw - p giu.Dummy(float32(float64(-(bw+p)/dpi)), 0).Build()
giu.Dummy(float32(math.Max(float64(dw/dpi), float64(-bw/dpi-p))), 0).Build()
giu.SameLine() giu.SameLine()
giu.Style().SetDisabled(len(allFiles) == 0 && len(onlyFiles) == 0).To( giu.Style().SetDisabled(len(allFiles) == 0 && len(onlyFiles) == 0).To(
giu.Button(s("Clear")).Size(bw/dpi, 0).OnClick(resetUI), giu.Button(s("Clear")).Size(bw/dpi, 0).OnClick(resetUI),
@ -821,7 +822,6 @@ func draw() {
), ),
), ),
giu.Dummy(0, 23),
// Input entry for validating a checksum // Input entry for validating a checksum
giu.Row( giu.Row(
giu.Label(s("Validate a checksum:")), giu.Label(s("Validate a checksum:")),
@ -899,7 +899,7 @@ func draw() {
).Build() ).Build()
} }
}), }),
giu.Dummy(0, -50), giu.Dummy(0, -46),
giu.Custom(func() { giu.Custom(func() {
w, _ := giu.GetAvailableRegion() w, _ := giu.GetAvailableRegion()
bw, _ := giu.CalcTextSize(s("Cancel")) bw, _ := giu.CalcTextSize(s("Cancel"))
@ -948,6 +948,12 @@ func draw() {
), ),
).Build() ).Build()
}), }),
giu.Custom(func() {
if !windowOptimized {
windowOptimized = true
window.SetSize(int(442*dpi), giu.GetCursorPos().Y+1)
}
}),
) )
} }
@ -1241,12 +1247,8 @@ func work() {
stat, _ := os.Stat(path) stat, _ := os.Stat(path)
header, _ := zip.FileInfoHeader(stat) header, _ := zip.FileInfoHeader(stat)
header.Name = strings.TrimPrefix(path, rootDir) header.Name = strings.TrimPrefix(path, rootDir)
header.Name = filepath.ToSlash(header.Name)
// Windows requires forward slashes in a .zip file
if runtime.GOOS == "windows" {
header.Name = strings.ReplaceAll(header.Name, "\\", "/")
header.Name = strings.TrimPrefix(header.Name, "/") header.Name = strings.TrimPrefix(header.Name, "/")
}
if compress { if compress {
header.Method = zip.Deflate header.Method = zip.Deflate
@ -2434,7 +2436,7 @@ func main() {
giu.SetDefaultFontFromBytes(font, 18) giu.SetDefaultFontFromBytes(font, 18)
// Create the master window // Create the master window
window := giu.NewMasterWindow("Picocrypt", 442, 532, giu.MasterWindowFlagsNotResizable) window = giu.NewMasterWindow("Picocrypt", 442, 532, giu.MasterWindowFlagsNotResizable)
dialog.Init() dialog.Init()
// Set window icon // Set window icon