File size: 3,499 Bytes
34097e9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
const dialog_box = require('../dialog_box')
const psapi = require('../psapi')
const { createBackgroundLayer } = require('./layer')
class Notification {
static {}
static async webuiIsOffline() {
const r1 = await dialog_box.prompt(
'Automatic1111 is Offline',
"make sure Automatic1111 is running in the background, or select the 'native horde' option from the horde tab",
['Cancel', 'OK']
)
try {
if (r1 === 'Cancel') {
/* cancelled or No */
console.log('cancel')
} else if (r1 === 'OK') {
console.log('ok')
}
} catch (e) {
console.warn(e)
}
}
static async webuiAPIMissing() {
const r1 = await dialog_box.prompt(
"The Plugin can't communicate with Automatic1111",
'Automatic1111 is running, but you forgot to add --api flag to the webui command flags',
['Cancel', 'OK']
)
try {
if (r1 === 'Cancel') {
/* cancelled or No */
console.log('cancel')
} else if (r1 === 'OK') {
console.log('ok')
}
} catch (e) {
console.warn(e)
}
}
static async backgroundLayerIsMissing() {
const r1 = await dialog_box.prompt(
'You need a white background layer present in your document',
'',
['Cancel', 'Create']
)
try {
if (r1 === 'Cancel') {
/* cancelled or No */
console.log('cancel')
return false
} else if (r1 === 'Create') {
//store the selection area and then unselected
const selectionInfo = await psapi.getSelectionInfoExe()
await psapi.unSelectMarqueeExe()
const active_layers = app.activeDocument.activeLayers
//create a background layer with no selection active
await createBackgroundLayer()
console.log('create background layer')
//reselect the selection area if it exist
await psapi.reSelectMarqueeExe(selectionInfo)
await psapi.selectLayersExe(active_layers)
return true
}
} catch (e) {
console.warn(e)
}
return false
}
static async inactiveSelectionArea(is_active_session) {
let buttons = ['Cancel', 'Rectangular Marquee']
if (is_active_session) {
buttons.push('Continue Session')
}
const r1 = await dialog_box.prompt(
'Please Select a Rectangular Area',
'You Forgot to select a Rectangular Area',
buttons
)
if (r1 === 'Cancel') {
/* cancelled or No */
console.log('cancel')
return false
} else if (r1 === 'Rectangular Marquee') {
console.log('Rectangular Marquee')
psapi.selectMarqueeRectangularToolExe()
return false // should this be false?! what does true and false means in this context?! Yes: it should be false since boolean value represent wither we have an active selection area or not
} else if (r1 === 'Continue Session') {
await activateSessionSelectionArea()
return true
}
return false
}
}
module.exports = {
Notification,
}
|